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:
Kai Jewson
2021-12-05 19:16:46 +01:00
committed by GitHub
parent cbb34869d8
commit dfb06e721c
41 changed files with 210 additions and 237 deletions
+6 -14
View File
@@ -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);