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 axum_core::body::Body #1584

Merged
merged 1 commit into from
Nov 27, 2022
Merged

Add axum_core::body::Body #1584

merged 1 commit into from
Nov 27, 2022

Conversation

davidpdrsn
Copy link
Member

This is part of the work towards 0.7.0

Hyper 1.0 is moving hyper::Body to hyper-util. That crate isn't stable so I don't think we should have it in axum's public API. This PR adds our own body type that just wraps another boxed body that we can use instead. It just adds the new type and doesn't actually use it yet. I'll do that in follow up PRs.

Generally my thinking is to replace Service impls with:

impl<B> Service<Request<B>> for Router<()>
where
    B: http_body::Body<Data = Bytes> + Send + 'static,
    B::Error: Into<BoxError>,
{
    fn call(&mut self, request: Request<B>) -> Self::Future {
        let request = request.map(|body| axum_core::Body::new(body));
        self.call_route(request)
    }

    // ...
}

So receive any boxable body but internally always use axum_core::Body. This means things don't need to be generic the request body which should be more ergonomic and fix issues such as #1110

axum_core::Body will also be re-exported at axum::body::Body for 0.7.0 but didn't do that here.

@davidpdrsn davidpdrsn added C-enhancement Category: A PR with an enhancement A-axum-core labels Nov 27, 2022
@davidpdrsn davidpdrsn added this to the 0.7 milestone Nov 27, 2022
@davidpdrsn davidpdrsn changed the title Add axum_core::Body Add axum_core::body::Body Nov 27, 2022
@davidpdrsn davidpdrsn merged commit 9793493 into v0.7.0 Nov 27, 2022
@davidpdrsn davidpdrsn deleted the v0.7.0-body branch November 27, 2022 10:57
davidpdrsn added a commit that referenced this pull request Feb 12, 2023
davidpdrsn added a commit that referenced this pull request Feb 16, 2023
davidpdrsn added a commit that referenced this pull request Feb 20, 2023
davidpdrsn added a commit that referenced this pull request Feb 24, 2023
davidpdrsn added a commit that referenced this pull request Feb 27, 2023
davidpdrsn added a commit that referenced this pull request Mar 10, 2023
davidpdrsn added a commit that referenced this pull request Mar 10, 2023
davidpdrsn added a commit that referenced this pull request Mar 17, 2023
davidpdrsn added a commit that referenced this pull request Mar 20, 2023
davidpdrsn added a commit that referenced this pull request Mar 23, 2023
davidpdrsn added a commit that referenced this pull request Apr 21, 2023
davidpdrsn added a commit that referenced this pull request Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-axum-core C-enhancement Category: A PR with an enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants