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 sure all middleware implement Service<Request<ReqBody>> and require Response = Response<ResBody> #164

Closed
davidpdrsn opened this issue Nov 15, 2021 · 0 comments · Fixed by #182
Assignees
Milestone

Comments

@davidpdrsn
Copy link
Member

For maximum flexibility in the future I think it makes sense to always implement Service like this:

impl<ReqBody, ResBody> Service<Request<ReqBody>> for Foo<S>
where
    S: Service<Request<ReqBody>, Response = Response<ResBody>>

That is they require the request type to be http::Request<_> and require the response of the inner service to be http::Response<_>.

If you only implement Service<R> then you don't have access to headers or extensions which might be necessary for implementing new features, same goes for the response. Case and point #156 which is a breaking change. That could have been avoided had ServeFile implemented Service<Request<_>>

For 0.2 I think we should go through all services fix this.

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 a pull request may close this issue.

2 participants