mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-10-31 20:34:12 +01:00
use axum body limit
This commit is contained in:
parent
a0a99cd3cc
commit
bd5acca97a
@ -1,5 +1,5 @@
|
|||||||
use axum::{
|
use axum::{
|
||||||
extract::Request,
|
extract::{DefaultBodyLimit, Request},
|
||||||
routing::{delete, get, post},
|
routing::{delete, get, post},
|
||||||
Router, ServiceExt,
|
Router, ServiceExt,
|
||||||
};
|
};
|
||||||
@ -7,7 +7,6 @@ use dotenv::dotenv;
|
|||||||
use tower::Layer;
|
use tower::Layer;
|
||||||
use tower_http::{
|
use tower_http::{
|
||||||
compression::CompressionLayer,
|
compression::CompressionLayer,
|
||||||
limit::RequestBodyLimitLayer,
|
|
||||||
normalize_path::NormalizePathLayer,
|
normalize_path::NormalizePathLayer,
|
||||||
services::{ServeDir, ServeFile},
|
services::{ServeDir, ServeFile},
|
||||||
};
|
};
|
||||||
@ -47,14 +46,14 @@ async fn main() {
|
|||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.nest("/api", api_routes)
|
.nest("/api", api_routes)
|
||||||
.fallback_service(serve_dir)
|
.fallback_service(serve_dir)
|
||||||
|
.layer(DefaultBodyLimit::max(*config::LIMIT))
|
||||||
.layer(
|
.layer(
|
||||||
CompressionLayer::new()
|
CompressionLayer::new()
|
||||||
.br(true)
|
.br(true)
|
||||||
.deflate(true)
|
.deflate(true)
|
||||||
.gzip(true)
|
.gzip(true)
|
||||||
.zstd(true),
|
.zstd(true),
|
||||||
)
|
);
|
||||||
.layer(RequestBodyLimitLayer::new(*config::LIMIT));
|
|
||||||
|
|
||||||
let app = NormalizePathLayer::trim_trailing_slash().layer(app);
|
let app = NormalizePathLayer::trim_trailing_slash().layer(app);
|
||||||
|
|
||||||
@ -62,9 +61,7 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("listening on {}", listener.local_addr().unwrap());
|
println!("listening on {}", listener.local_addr().unwrap());
|
||||||
println!("Config {}", *config::LIMIT);
|
|
||||||
axum::serve(listener, ServiceExt::<Request>::into_make_service(app))
|
axum::serve(listener, ServiceExt::<Request>::into_make_service(app))
|
||||||
// axum::serve(listener, app)
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user