You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example use case:
Respond with too many requests http status code in case ConcurrencyLimitLayer is not ready.
let concurrency_layer = LoadShedLayer::new().layer(ConcurrencyLimitLayer::new(100));
This did not work for me
let handle_error_layer = HandleErrorLayer::new(handle_concurrency_error);// from axumasyncfnhandle_concurrency_error(// `Method` and `Uri` are extractors so they can be used heremethod:Method,uri:Uri,// the last argument must be the error itselferr: tower::BoxError,) -> (StatusCode,String){(StatusCode::TOO_MANY_REQUESTS,format!("`{method} {uri}` failed with {err}"),)}let concurrency_layer = LoadShedLayer::new().layer(ConcurrencyLimitLayer::new(100));Server::builder().layer(handle_error_layer).layer(concurrency_layer)
Error:
--> src/lib.rs:144:10
|
144 | .serve(addr)
| ^^^^^ the trait `tower::Layer<SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<tower_http::trace::Trace<Routes,SharedClassifier<GrpcErrorsAsFailures>,{closure@src/lib.rs:94:25:94:53}>>>>` is not implemented for `LoadShed<ConcurrencyLimitLayer>`, which is required by `Stack<LoadShed<ConcurrencyLimitLayer>,Stack<HandleErrorLayer<fn(Method,Uri,Box<(dyn std::error::Error + Send + Sync + 'static)>) -> implFuture<Output = (http::StatusCode, std::string::String)> {handle_concurrency_error}, _>, tower::layer::util::Identity>>: tower::Layer<SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<tower_http::trace::Trace<Routes,SharedClassifier<GrpcErrorsAsFailures>,{closure@src/lib.rs:94:25:94:53}>>>>`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Axum provides https://docs.rs/axum/0.7.5/axum/error_handling/struct.HandleErrorLayer.html
Example use case:
Respond with
too many requests
http status code in caseConcurrencyLimitLayer
is not ready.This did not work for me
Error:
Beta Was this translation helpful? Give feedback.
All reactions