Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware composition docs #6055

Open
devon-whil opened this issue Feb 17, 2022 · 0 comments
Open

Middleware composition docs #6055

devon-whil opened this issue Feb 17, 2022 · 0 comments
Labels
docs Relates to our website or tutorials

Comments

@devon-whil
Copy link

I think the middleware composition docs are somewhat confusing/misleading.
https://http4s.org/v0.23/middleware/#composing-services-with-middleware

val aggregateService = apiService <+> MyMiddle(service, "SomeKey" -> "SomeValue")

Note that goodRequest ran through the MyMiddle middleware and the Result had our header added to it. But, apiRequest did not go through the middleware and did not have the header added to it’s Result.

It's not obvious that if I reverse those then apiRequest would get the header added.

I don't use the Authentication middleware, but I stumbled my way to here to figure out how a request flows through a composition of routes and middlewares.

val service: HttpRoutes[IO] = middleware(spanishRoutes) <+> frenchRoutes

Call to the french routes will always return 401 (Unauthorized) as they are caught by the spanish routes.

I think information about how a request flows through a composition of routes and middlewares and how to apply middleware to specific routes would be helpful on the middleware page.

@armanbilge armanbilge added the docs Relates to our website or tutorials label Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Relates to our website or tutorials
Projects
None yet
Development

No branches or pull requests

2 participants