mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-22 00:00:17 +02:00
Support returning any http_body::Body from IntoResponse (#86)
Adds associated `Body` and `BodyError` types to `IntoResponse`. This is required for returning responses with bodies other than `hyper::Body` from handlers. That wasn't previously possible. This is a breaking change so should be shipped in 0.2.
This commit is contained in:
@@ -10,8 +10,10 @@ use axum::{
|
||||
extract::{FromRequest, RequestParts},
|
||||
prelude::*,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use http::Response;
|
||||
use http::StatusCode;
|
||||
use http_body::Full;
|
||||
use std::collections::HashMap;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
@@ -51,7 +53,7 @@ impl<B> FromRequest<B> for Version
|
||||
where
|
||||
B: Send,
|
||||
{
|
||||
type Rejection = Response<Body>;
|
||||
type Rejection = Response<Full<Bytes>>;
|
||||
|
||||
async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
|
||||
let params = extract::Path::<HashMap<String, String>>::from_request(req)
|
||||
|
||||
Reference in New Issue
Block a user