v0.2.93
This commit is contained in:
1 parent
b85201889e
commit
b035648b81
21 files changed
+318
-73
No files matched your search
+19
-5
@@ -50,6 +50,7 @@ pub fn router(
|
||||
upload_body_limit_bytes: usize,
|
||||
asset_cache_max_age_seconds: u64,
|
||||
http_compression: bool,
|
||||
serve_files_on_application: bool,
|
||||
) -> Router {
|
||||
let asset_version = state.asset_version.clone();
|
||||
let asset_not_found = service_fn(move |_request| {
|
||||
@@ -71,7 +72,7 @@ pub fn router(
|
||||
HeaderValue::from_str(&crate::cache::cache_control(asset_cache_max_age_seconds))
|
||||
.expect("valid asset cache-control header");
|
||||
|
||||
Router::new()
|
||||
let mut app = Router::new()
|
||||
.route("/", get(home))
|
||||
.route("/auth/confirm/{token}", get(home))
|
||||
.route("/auth/reset-password/{token}", get(home))
|
||||
@@ -92,7 +93,6 @@ pub fn router(
|
||||
.route("/icons/favicon.svg", get(favicon_svg))
|
||||
.route("/icons/favicon-32.png", get(favicon_png))
|
||||
.route("/icons/apple-touch-icon.png", get(apple_touch_icon))
|
||||
.route("/f/{token}/{filename}", get(api::download_file))
|
||||
.route("/api/auth/identity", post(auth::identity))
|
||||
.route(
|
||||
"/api/security/csrf",
|
||||
@@ -256,12 +256,16 @@ pub fn router(
|
||||
.service(ServeDir::new(static_dir).not_found_service(asset_not_found)),
|
||||
)
|
||||
.fallback(not_found)
|
||||
.method_not_allowed_fallback(method_not_allowed)
|
||||
.layer(DefaultBodyLimit::max(upload_body_limit_bytes))
|
||||
.method_not_allowed_fallback(method_not_allowed);
|
||||
|
||||
if serve_files_on_application {
|
||||
app = app.route("/f/{token}/{filename}", get(api::download_file));
|
||||
}
|
||||
|
||||
app.layer(DefaultBodyLimit::max(upload_body_limit_bytes))
|
||||
.layer(TraceLayer::new_for_http().make_span_with(PathOnlyMakeSpan))
|
||||
.layer(middleware::from_fn(require_csrf_token))
|
||||
.layer(middleware::from_fn(apply_response_header_policy))
|
||||
// Negotiate HTTP compression only when enabled; WebSocket frames are unaffected.
|
||||
.layer(
|
||||
CompressionLayer::new()
|
||||
.br(http_compression)
|
||||
@@ -270,6 +274,16 @@ pub fn router(
|
||||
.with_state(state)
|
||||
}
|
||||
|
||||
pub fn files_router(state: SharedState) -> Router {
|
||||
Router::new()
|
||||
.route("/health", get(health))
|
||||
.route("/f/{token}/{filename}", get(api::download_file))
|
||||
.fallback(|| async { StatusCode::NOT_FOUND })
|
||||
.layer(TraceLayer::new_for_http().make_span_with(PathOnlyMakeSpan))
|
||||
.layer(middleware::from_fn(apply_response_header_policy))
|
||||
.with_state(state)
|
||||
}
|
||||
|
||||
async fn language_catalog() -> Response {
|
||||
let mut response = Json(crate::i18n::metadata()).into_response();
|
||||
response.headers_mut().insert(
|
||||
|
||||
Reference in new issue
Block a user