reordering layers so the web server works in non-debug-mode (#1999)

This commit is contained in:
James Hodgkinson 2023-08-19 11:00:53 +10:00 committed by GitHub
parent f6001504a9
commit 01cdeedc72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -255,17 +255,17 @@ pub async fn create_https_server(
)); ));
// layer which checks the responses have a content-type of JSON when we're in debug mode // layer which checks the responses have a content-type of JSON when we're in debug mode
#[cfg(any(test, debug_assertions))] #[cfg(any(test, debug_assertions))]
let app = app.layer(from_fn(middleware::are_we_json_yet)); let app = app.layer(from_fn(middleware::are_we_json_yet));
let app = app let app = app
.layer(trace_layer)
// This must be the LAST middleware. // This must be the LAST middleware.
// This is because the last middleware here is the first to be entered and the last // This is because the last middleware here is the first to be entered and the last
// to be exited, and this middleware sets up ids' and other bits for for logging // to be exited, and this middleware sets up ids' and other bits for for logging
// coherence to be maintained. // coherence to be maintained.
.layer(from_fn(middleware::kopid_middleware)) .layer(from_fn(middleware::kopid_middleware))
// this MUST be the last layer before with_state else the span never starts and everything breaks.
.layer(trace_layer)
.with_state(state) .with_state(state)
// the connect_info bit here lets us pick up the remote address of the client // the connect_info bit here lets us pick up the remote address of the client
.into_make_service_with_connect_info::<SocketAddr>(); .into_make_service_with_connect_info::<SocketAddr>();