Accept S::Response: IntoResponse everywhere (#1165)

This commit is contained in:
David Pedersen
2022-07-19 18:55:15 +02:00
committed by GitHub
parent 643909af6d
commit b243e171fd
11 changed files with 96 additions and 99 deletions
+5 -3
View File
@@ -3,7 +3,7 @@
use axum::{
handler::Handler,
http::Request,
response::{Redirect, Response},
response::{IntoResponse, Redirect},
Router,
};
use std::{convert::Infallible, future::ready};
@@ -161,7 +161,8 @@ pub trait RouterExt<B>: sealed::Sealed {
/// ```
fn route_with_tsr<T>(self, path: &str, service: T) -> Self
where
T: Service<Request<B>, Response = Response, Error = Infallible> + Clone + Send + 'static,
T: Service<Request<B>, Error = Infallible> + Clone + Send + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
Self: Sized;
}
@@ -252,7 +253,8 @@ where
fn route_with_tsr<T>(mut self, path: &str, service: T) -> Self
where
T: Service<Request<B>, Response = Response, Error = Infallible> + Clone + Send + 'static,
T: Service<Request<B>, Error = Infallible> + Clone + Send + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
Self: Sized,
{
+7 -4
View File
@@ -2,7 +2,7 @@ use axum::{
body::Body,
handler::Handler,
http::Request,
response::Response,
response::IntoResponse,
routing::{delete, get, on, post, MethodFilter},
Router,
};
@@ -141,7 +141,8 @@ where
/// 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, Error = Infallible> + Clone + Send + 'static,
T: Service<Request<B>, Error = Infallible> + Clone + Send + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
let path = self.show_update_destroy_path();
@@ -154,7 +155,8 @@ where
/// 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, Error = Infallible> + Clone + Send + 'static,
T: Service<Request<B>, Error = Infallible> + Clone + Send + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
let path = self.index_create_path();
@@ -172,7 +174,8 @@ where
fn route<T>(mut self, path: &str, svc: T) -> Self
where
T: Service<Request<B>, Response = Response, Error = Infallible> + Clone + Send + 'static,
T: Service<Request<B>, Error = Infallible> + Clone + Send + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
self.router = self.router.route(path, svc);
+3 -3
View File
@@ -1,7 +1,7 @@
use axum::{
body::{Body, HttpBody},
error_handling::HandleError,
response::Response,
response::IntoResponse,
routing::{get_service, Route},
Router,
};
@@ -150,8 +150,8 @@ impl<B, T, F> SpaRouter<B, T, F> {
impl<B, F, T> From<SpaRouter<B, T, F>> for Router<B>
where
F: Clone + Send + 'static,
HandleError<Route<B, io::Error>, F, T>:
Service<Request<B>, Response = Response, Error = Infallible>,
HandleError<Route<B, io::Error>, F, T>: Service<Request<B>, Error = Infallible>,
<HandleError<Route<B, io::Error>, F, T> as Service<Request<B>>>::Response: IntoResponse + Send,
<HandleError<Route<B, io::Error>, F, T> as Service<Request<B>>>::Future: Send,
B: HttpBody + Send + 'static,
T: 'static,