Skip to content

Handling Error with appstate #2272

Answered by davidpdrsn
0xpr03 asked this question in Q&A
Oct 15, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

early-return in handlers when no valid login could be found

Make your own extractor or middleware.

use some kind of IntoResponse AppError

IntoResponse intentionally doesn’t access to state so you have to pass that in some other way.

render that error for all handlers with a template system that requires access to the AppState and also possibly more context

This also sounds like a middleware to me. Perhaps the handler sets a response extension which is picked up by a middleware and then converted into a response.

Replies: 1 comment 2 replies

Comment options

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

@davidpdrsn
Comment options

Answer selected by 0xpr03
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