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

make service infallible #132

Merged
merged 1 commit into from
Jan 1, 2024
Merged

make service infallible #132

merged 1 commit into from
Jan 1, 2024

Conversation

maxcountryman
Copy link
Owner

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:

  • MissingId
  • MissingCookies

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:

- `MissingId`
- `MissingCookies`
Copy link

codecov bot commented Dec 31, 2023

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 ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maxcountryman maxcountryman merged commit cb60f10 into main Jan 1, 2024
11 of 13 checks passed
@maxcountryman maxcountryman deleted the service-errors branch January 1, 2024 15:21
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.

1 participant