Skip to content

Conversation

omer9564
Copy link

Fixes #3421

Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Left some comments.

first add your routes and then call `route_layer` afterwards. Additional routes
added after `route_layer` is called will not have the middleware added.

**Important**: The middleware is NOT applied to fallback handlers. Fallback handlers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph is redundant with the one after it. Maybe that one isn't quite clear, but I don't think leaving it as-is and adding an extra one before it is the right fix. Can you think about how to merge these two paragraphs?

Comment on lines +32 to +37
.fallback(|| async { "fallback" })
.route_layer(ValidateRequestHeaderLayer::bearer("password"));

// `GET /foo` with a valid token will receive `200 OK`
// `GET /foo` with a invalid token will receive `401 Unauthorized`
// `GET /not-found` with a invalid token will receive `404 Not Found`
// `GET /not-found` with a invalid token will receive `200 OK` (fallback)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this example benefits from having an explicit fallback handler. Why did you add that? Maybe just add (default fallback handler) after the 404 Not Found?

@jplatte
Copy link
Member

jplatte commented Aug 12, 2025

Hey @omer9564, do you plan to get back to this and address the review feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading docs for route_layer
2 participants