fix: classify 4xx as failure, move trace layer up
This commit is contained in:
parent
0097a0533a
commit
fffb562ddb
1 changed files with 7 additions and 3 deletions
|
@ -1,3 +1,5 @@
|
|||
use tower_http::classify::{SharedClassifier, StatusInRangeAsFailures};
|
||||
|
||||
pub mod activitypub;
|
||||
|
||||
#[cfg(feature = "mastodon")]
|
||||
|
@ -23,11 +25,11 @@ pub async fn serve(ctx: upub::Context, bind: String) -> upub::Result<()> {
|
|||
use tower_http::{cors::CorsLayer, trace::TraceLayer};
|
||||
|
||||
let router = axum::Router::new()
|
||||
.ap_routes()
|
||||
.mastodon_routes() // no-op if mastodon feature is disabled
|
||||
.layer(CorsLayer::permissive())
|
||||
.layer(
|
||||
TraceLayer::new_for_http()
|
||||
// TODO 4xx errors aren't really failures but since upub is in development it's useful to log
|
||||
// these too, in case something's broken
|
||||
TraceLayer::new(SharedClassifier::new(StatusInRangeAsFailures::new(300..=u16::MAX)))
|
||||
.make_span_with(|req: &axum::http::Request<_>| {
|
||||
tracing::span!(
|
||||
tracing::Level::INFO,
|
||||
|
@ -37,6 +39,8 @@ pub async fn serve(ctx: upub::Context, bind: String) -> upub::Result<()> {
|
|||
)
|
||||
})
|
||||
)
|
||||
.ap_routes()
|
||||
.mastodon_routes() // no-op if mastodon feature is disabled
|
||||
.with_state(ctx);
|
||||
|
||||
// run our app with hyper, listening locally on port 3000
|
||||
|
|
Loading…
Reference in a new issue