Skip to content
Discussion options

You must be logged in to vote

Is this the correct ordering of layers so all have a 20s timeout but only /cacluate is protected by the protected middleware?

Yes, though I perfer .route("/calculate", post(...).layer(...)). I think thats more clear but it ultimately doesn't matter.

How can I take the result returned from routes::protected and log an error?

I think you're misunderstanding how axum thinks about errors. Returning 500 Internal Server (or some other status) from a handler is not an error. Thats just another response. Errors only occur when you apply fallible middleware like TimeoutLayer. Notice that it's error type isn't Infallible which axum requires.

I recommend you just log error directly in routes::pr…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@zkrzyzanowski
Comment options

@davidpdrsn
Comment options

Answer selected by zkrzyzanowski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants