maxcountryman / tower-sessions

🥠 Sessions as a `tower` and `axum` middleware.
MIT License
249 stars 43 forks source link

make service infallible #132

Closed maxcountryman closed 10 months ago

maxcountryman commented 10 months ago

This reworks the tower service such that we always return a response. In other words, the service becomes infallible. What this means is we no longer need to build an intermediary service that captures boxed errors when using this crate with axum.

One side effect of this is that we lose the ability to handle specific errors, such as the session save failing, via downcasting. Instead, the middleware will return a 500 response. To address this, we could extend this implementation to allow for an on error callback, which could take an error and return a response.

This is a breaking change which also removes two extraneous variants from the session error type:

codecov[bot] commented 10 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (b59749c) 75.89% compared to head (3ec66f6) 74.70%.

Files Patch % Lines
tower-sessions-core/src/service.rs 30.76% 9 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #132 +/- ## ========================================== - Coverage 75.89% 74.70% -1.20% ========================================== Files 12 12 Lines 502 510 +8 ========================================== Hits 381 381 - Misses 121 129 +8 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.