-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Allow any error type in handler result #89
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #89 +/- ##
==========================================
+ Coverage 57.38% 57.43% +0.05%
==========================================
Files 7 7
Lines 1368 1365 -3
==========================================
- Hits 785 784 -1
+ Misses 583 581 -2 ☔ View full report in Codecov by Sentry. |
See my PR against this branch for tests and usage. This is a good step, but I think we should do more to improve ergonomics. |
See the second commit. That would get us in trouble with Epoxide, though, which has this impl: impl FromContext<'_, App> for Session {
fn from_context(
app: &'_ Arc<App>,
req: &'_ Parts,
_: &mut mendes::application::PathState,
_: &mut Option<<App as Application>::RequestBody>,
) -> Result<Session, Error> {
app.cookie::<Self>(&req.headers)
.ok_or_else(|| Error::forbidden("not logged in"))
}
} I guess we could add a |
I think this would limit the usefulness of the Currently it expands to pub(super) async fn handler(
cx: &mut mendes::application::Context<App>,
) -> Result<Response<String>, HandlerError> {
match &cx.req.method {
&mendes::http::Method::GET => {}
_ => return Err(mendes::Error::MethodNotAllowed.into()),
}
let _0 = <&App as mendes::FromContext<
App,
>>::from_context(&cx.app, &cx.req, &mut cx.path, &mut cx.body)?;
call(_0).await
} What if we would change the signature of On the other side, keeping it this way, forcing the user to implement |
All other things being equal, this feels preferable to me? |
I agree. Do you want me to update the PR test adds the tests so that PR can be merged into this PR or do you want to merge this first and merge the test PR into main afterwards? |
I don't really care -- the state on |
043089b
to
9250f8a
Compare
I think there is a misunderstanding. I think with
I was referencing the state without the Edit: And you keep the freedom to provide your own |
4d56552
to
4bf5dbd
Compare
Alright, that makes sense to me. I'll see what happens if I plug this into bolt before we merge it. |
Seems to just work in bolt. Merging! |
The changes in #89 were actually semver-compatible, since they merely widen the blanket impl of IntoResponse for Result.
r? @valkum