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

Add option_layer #1696

Merged
merged 5 commits into from
Feb 11, 2023
Merged

Add option_layer #1696

merged 5 commits into from
Feb 11, 2023

Conversation

davidpdrsn
Copy link
Member

Tower already has option_layer for conditionally applying a Layer but since it uses tower::util::Either it always changes the error type to BoxError. That requires using HandleErrorLayer which is inconvenient for axum users.

That has been changed in tower
(tower-rs/tower#637) but still has some issues (tower-rs/tower#665). Its also a breaking change so hasn't been released yet.

In the meantime I figure we can provide our own thing in axum-extra, since we already have an Either type there.

Tower already has `option_layer` for conditionally applying a `Layer`
but since it uses `tower::util::Either` it always changes the error type
to `BoxError`. That requires using `HandleErrorLayer` which is
inconvenient for axum users.

That has been changed in tower
(tower-rs/tower#637) but still has some issues
(tower-rs/tower#665). Its also a breaking
change so hasn't been released yet.

In the meantime I figure we can provide our own thing in axum-extra,
since we already have an `Either` type there.
@davidpdrsn davidpdrsn enabled auto-merge (squash) January 14, 2023 14:00
Copy link

@Oliboy50 Oliboy50 left a comment

Choose a reason for hiding this comment

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

🙇

axum-extra/src/middleware.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants