mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-02 00:00:22 +02:00
Introduce Response type alias as a shorthand for Response<BoxBody> (#590)
* Introduce `Response` type alias as a shorthand * Don't re-export `Response` at the crate root
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
use axum::{
|
||||
async_trait,
|
||||
body::BoxBody,
|
||||
extract::{
|
||||
rejection::{ExtensionRejection, ExtensionsAlreadyExtracted},
|
||||
Extension, FromRequest, RequestParts,
|
||||
},
|
||||
http::Response,
|
||||
response::IntoResponse,
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use std::{
|
||||
fmt,
|
||||
@@ -31,8 +29,8 @@ use std::{
|
||||
/// async_trait,
|
||||
/// extract::{FromRequest, RequestParts},
|
||||
/// body::BoxBody,
|
||||
/// response::IntoResponse,
|
||||
/// http::{StatusCode, Response},
|
||||
/// response::{IntoResponse, Response},
|
||||
/// http::StatusCode,
|
||||
/// };
|
||||
///
|
||||
/// #[derive(Clone)]
|
||||
@@ -58,7 +56,7 @@ use std::{
|
||||
/// where
|
||||
/// B: Send,
|
||||
/// {
|
||||
/// type Rejection = Response<BoxBody>;
|
||||
/// type Rejection = Response;
|
||||
///
|
||||
/// async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
|
||||
/// // loading a `CurrentUser` requires first loading the `Session`
|
||||
@@ -157,7 +155,7 @@ impl<R> IntoResponse for CachedRejection<R>
|
||||
where
|
||||
R: IntoResponse,
|
||||
{
|
||||
fn into_response(self) -> Response<BoxBody> {
|
||||
fn into_response(self) -> Response {
|
||||
match self {
|
||||
Self::ExtensionsAlreadyExtracted(inner) => inner.into_response(),
|
||||
Self::Inner(inner) => inner.into_response(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use axum::{
|
||||
body::{self, BoxBody, Full},
|
||||
http::{header, HeaderValue, Response, StatusCode},
|
||||
response::IntoResponse,
|
||||
body::{self, Full},
|
||||
http::{header, HeaderValue, StatusCode},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -39,7 +39,7 @@ impl ErasedJson {
|
||||
}
|
||||
|
||||
impl IntoResponse for ErasedJson {
|
||||
fn into_response(self) -> Response<BoxBody> {
|
||||
fn into_response(self) -> Response {
|
||||
let bytes = match self.0 {
|
||||
Ok(res) => res,
|
||||
Err(err) => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use super::HasRoutes;
|
||||
use axum::{
|
||||
body::{Body, BoxBody},
|
||||
body::Body,
|
||||
handler::Handler,
|
||||
http::{Request, Response},
|
||||
http::Request,
|
||||
response::Response,
|
||||
routing::{delete, get, on, post, MethodFilter},
|
||||
Router,
|
||||
};
|
||||
@@ -139,10 +140,7 @@ impl<B: Send + 'static> Resource<B> {
|
||||
/// The routes will be nested at `/{resource_name}/:{resource_name}_id`.
|
||||
pub fn nest<T>(mut self, svc: T) -> Self
|
||||
where
|
||||
T: Service<Request<B>, Response = Response<BoxBody>, Error = Infallible>
|
||||
+ Clone
|
||||
+ Send
|
||||
+ 'static,
|
||||
T: Service<Request<B>, Response = Response, Error = Infallible> + Clone + Send + 'static,
|
||||
T::Future: Send + 'static,
|
||||
{
|
||||
let path = self.show_update_destroy_path();
|
||||
@@ -155,10 +153,7 @@ impl<B: Send + 'static> Resource<B> {
|
||||
/// The routes will be nested at `/{resource_name}`.
|
||||
pub fn nest_collection<T>(mut self, svc: T) -> Self
|
||||
where
|
||||
T: Service<Request<B>, Response = Response<BoxBody>, Error = Infallible>
|
||||
+ Clone
|
||||
+ Send
|
||||
+ 'static,
|
||||
T: Service<Request<B>, Response = Response, Error = Infallible> + Clone + Send + 'static,
|
||||
T::Future: Send + 'static,
|
||||
{
|
||||
let path = self.index_create_path();
|
||||
@@ -176,10 +171,7 @@ impl<B: Send + 'static> Resource<B> {
|
||||
|
||||
fn route<T>(mut self, path: &str, svc: T) -> Self
|
||||
where
|
||||
T: Service<Request<B>, Response = Response<BoxBody>, Error = Infallible>
|
||||
+ Clone
|
||||
+ Send
|
||||
+ 'static,
|
||||
T: Service<Request<B>, Response = Response, Error = Infallible> + Clone + Send + 'static,
|
||||
T::Future: Send + 'static,
|
||||
{
|
||||
self.router = self.router.route(path, svc);
|
||||
|
||||
Reference in New Issue
Block a user