summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Pedersen <david.pdrsn@gmail.com>2024-09-28 23:28:44 +0200
committerGitHub <noreply@github.com>2024-09-28 23:28:44 +0200
commit52fd139a862bfed2e910352dc93eeb142c2f83c9 (patch)
tree77c4133f950998c8225e9e43739a78c3d676dd93
parent19101f624d471856b71b273a01189a0dcb4468c7 (diff)
Require `Sync` for services (#2473)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
-rw-r--r--axum-extra/src/handler/mod.rs2
-rw-r--r--axum-extra/src/handler/or.rs4
-rw-r--r--axum-extra/src/routing/mod.rs4
-rw-r--r--axum/CHANGELOG.md4
-rw-r--r--axum/src/box_clone_service.rs80
-rw-r--r--axum/src/boxed.rs10
-rw-r--r--axum/src/handler/mod.rs10
-rw-r--r--axum/src/lib.rs1
-rw-r--r--axum/src/middleware/from_fn.rs6
-rw-r--r--axum/src/routing/method_routing.rs21
-rw-r--r--axum/src/routing/mod.rs20
-rw-r--r--axum/src/routing/path_router.rs12
-rw-r--r--axum/src/routing/route.rs7
-rw-r--r--clippy.toml3
14 files changed, 137 insertions, 47 deletions
diff --git a/axum-extra/src/handler/mod.rs b/axum-extra/src/handler/mod.rs
index 915852a1..c3bf7024 100644
--- a/axum-extra/src/handler/mod.rs
+++ b/axum-extra/src/handler/mod.rs
@@ -165,7 +165,7 @@ pub struct IntoHandler<H, T, S> {
impl<H, T, S> Handler<T, S> for IntoHandler<H, T, S>
where
- H: HandlerCallWithExtractors<T, S> + Clone + Send + 'static,
+ H: HandlerCallWithExtractors<T, S> + Clone + Send + Sync + 'static,
T: FromRequest<S> + Send + 'static,
T::Rejection: Send,
S: Send + Sync + 'static,
diff --git a/axum-extra/src/handler/or.rs b/axum-extra/src/handler/or.rs
index 0a468db7..faa68516 100644
--- a/axum-extra/src/handler/or.rs
+++ b/axum-extra/src/handler/or.rs
@@ -54,8 +54,8 @@ where
impl<S, L, R, Lt, Rt, M> Handler<(M, Lt, Rt), S> for Or<L, R, Lt, Rt, S>
where
- L: HandlerCallWithExtractors<Lt, S> + Clone + Send + 'static,
- R: HandlerCallWithExtractors<Rt, S> + Clone + Send + 'static,
+ L: HandlerCallWithExtractors<Lt, S> + Clone + Send + Sync + 'static,
+ R: HandlerCallWithExtractors<Rt, S> + Clone + Send + Sync + 'static,
Lt: FromRequestParts<S> + Send + 'static,
Rt: FromRequest<S, M> + Send + 'static,
Lt::Rejection: Send,
diff --git a/axum-extra/src/routing/mod.rs b/axum-extra/src/routing/mod.rs
index a294c547..bf99bbcf 100644
--- a/axum-extra/src/routing/mod.rs
+++ b/axum-extra/src/routing/mod.rs
@@ -165,7 +165,7 @@ pub trait RouterExt<S>: sealed::Sealed {
/// This works like [`RouterExt::route_with_tsr`] but accepts any [`Service`].
fn route_service_with_tsr<T>(self, path: &str, service: T) -> Self
where
- T: Service<Request, Error = Infallible> + Clone + Send + 'static,
+ T: Service<Request, Error = Infallible> + Clone + Send + Sync + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
Self: Sized;
@@ -268,7 +268,7 @@ where
#[track_caller]
fn route_service_with_tsr<T>(mut self, path: &str, service: T) -> Self
where
- T: Service<Request, Error = Infallible> + Clone + Send + 'static,
+ T: Service<Request, Error = Infallible> + Clone + Send + Sync + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
Self: Sized,
diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md
index b897e757..47b69e2c 100644
--- a/axum/CHANGELOG.md
+++ b/axum/CHANGELOG.md
@@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased
+- **breaking:** Require `Sync` for all handlers and services added to `Router`
+ and `MethodRouter` ([#2473])
- **breaking:** The tuple and tuple_struct `Path` extractor deserializers now check that the number of parameters matches the tuple length exactly ([#2931])
- **change:** Update minimum rust version to 1.75 ([#2943])
+[#2473]: https://github.com/tokio-rs/axum/pull/2473
[#2931]: https://github.com/tokio-rs/axum/pull/2931
[#2943]: https://github.com/tokio-rs/axum/pull/2943
@@ -55,7 +58,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2201]: https://github.com/tokio-rs/axum/pull/2201
[#2483]: https://github.com/tokio-rs/axum/pull/2483
-[#2201]: https://github.com/tokio-rs/axum/pull/2201
[#2484]: https://github.com/tokio-rs/axum/pull/2484
# 0.7.3 (29. December, 2023)
diff --git a/axum/src/box_clone_service.rs b/axum/src/box_clone_service.rs
new file mode 100644
index 00000000..25c0b205
--- /dev/null
+++ b/axum/src/box_clone_service.rs
@@ -0,0 +1,80 @@
+use futures_util::future::BoxFuture;
+use std::{
+ fmt,
+ task::{Context, Poll},
+};
+use tower::ServiceExt;
+use tower_service::Service;
+
+/// Like `tower::BoxCloneService` but `Sync`
+pub(crate) struct BoxCloneService<T, U, E>(
+ Box<
+ dyn CloneService<T, Response = U, Error = E, Future = BoxFuture<'static, Result<U, E>>>
+ + Send
+ + Sync,
+ >,
+);
+
+impl<T, U, E> BoxCloneService<T, U, E> {
+ pub(crate) fn new<S>(inner: S) -> Self
+ where
+ S: Service<T, Response = U, Error = E> + Clone + Send + Sync + 'static,
+ S::Future: Send + 'static,
+ {
+ let inner = inner.map_future(|f| Box::pin(f) as _);
+ BoxCloneService(Box::new(inner))
+ }
+}
+
+impl<T, U, E> Service<T> for BoxCloneService<T, U, E> {
+ type Response = U;
+ type Error = E;
+ type Future = BoxFuture<'static, Result<U, E>>;
+
+ #[inline]
+ fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), E>> {
+ self.0.poll_ready(cx)
+ }
+
+ #[inline]
+ fn call(&mut self, request: T) -> Self::Future {
+ self.0.call(request)
+ }
+}
+
+impl<T, U, E> Clone for BoxCloneService<T, U, E> {
+ fn clone(&self) -> Self {
+ Self(self.0.clone_box())
+ }
+}
+
+trait CloneService<R>: Service<R> {
+ fn clone_box(
+ &self,
+ ) -> Box<
+ dyn CloneService<R, Response = Self::Response, Error = Self::Error, Future = Self::Future>
+ + Send
+ + Sync,
+ >;
+}
+
+impl<R, T> CloneService<R> for T
+where
+ T: Service<R> + Send + Sync + Clone + 'static,
+{
+ fn clone_box(
+ &self,
+ ) -> Box<
+ dyn CloneService<R, Response = T::Response, Error = T::Error, Future = T::Future>
+ + Send
+ + Sync,
+ > {
+ Box::new(self.clone())
+ }
+}
+
+impl<T, U, E> fmt::Debug for BoxCloneService<T, U, E> {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fmt.debug_struct("BoxCloneService").finish()
+ }
+}
diff --git a/axum/src/boxed.rs b/axum/src/boxed.rs
index 32808f51..6347de58 100644
--- a/axum/src/boxed.rs
+++ b/axum/src/boxed.rs
@@ -33,7 +33,7 @@ impl<S, E> BoxedIntoRoute<S, E> {
where
S: 'static,
E: 'static,
- F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + 'static,
+ F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + Sync + 'static,
E2: 'static,
{
BoxedIntoRoute(AxumMutex::new(Box::new(Map {
@@ -59,7 +59,7 @@ impl<S, E> fmt::Debug for BoxedIntoRoute<S, E> {
}
}
-pub(crate) trait ErasedIntoRoute<S, E>: Send {
+pub(crate) trait ErasedIntoRoute<S, E>: Send + Sync {
fn clone_box(&self) -> Box<dyn ErasedIntoRoute<S, E>>;
fn into_route(self: Box<Self>, state: S) -> Route<E>;
@@ -75,7 +75,7 @@ pub(crate) struct MakeErasedHandler<H, S> {
impl<H, S> ErasedIntoRoute<S, Infallible> for MakeErasedHandler<H, S>
where
- H: Clone + Send + 'static,
+ H: Clone + Send + Sync + 'static,
S: 'static,
{
fn clone_box(&self) -> Box<dyn ErasedIntoRoute<S, Infallible>> {
@@ -165,13 +165,13 @@ where
}
}
-pub(crate) trait LayerFn<E, E2>: FnOnce(Route<E>) -> Route<E2> + Send {
+pub(crate) trait LayerFn<E, E2>: FnOnce(Route<E>) -> Route<E2> + Send + Sync {
fn clone_box(&self) -> Box<dyn LayerFn<E, E2>>;
}
impl<F, E, E2> LayerFn<E, E2> for F
where
- F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + 'static,
+ F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + Sync + 'static,
{
fn clone_box(&self) -> Box<dyn LayerFn<E, E2>> {
Box::new(self.clone())
diff --git a/axum/src/handler/mod.rs b/axum/src/handler/mod.rs
index 04c66c4a..8485390b 100644
--- a/axum/src/handler/mod.rs
+++ b/axum/src/handler/mod.rs
@@ -131,7 +131,7 @@ pub use self::service::HandlerService;
note = "Consider using `#[axum::debug_handler]` to improve the error message"
)
)]
-pub trait Handler<T, S>: Clone + Send + Sized + 'static {
+pub trait Handler<T, S>: Clone + Send + Sync + Sized + 'static {
/// The type of future calling this handler returns.
type Future: Future<Output = Response> + Send + 'static;
@@ -192,7 +192,7 @@ pub trait Handler<T, S>: Clone + Send + Sized + 'static {
impl<F, Fut, Res, S> Handler<((),), S> for F
where
- F: FnOnce() -> Fut + Clone + Send + 'static,
+ F: FnOnce() -> Fut + Clone + Send + Sync + 'static,
Fut: Future<Output = Res> + Send,
Res: IntoResponse,
{
@@ -210,7 +210,7 @@ macro_rules! impl_handler {
#[allow(non_snake_case, unused_mut)]
impl<F, Fut, S, Res, M, $($ty,)* $last> Handler<(M, $($ty,)* $last,), S> for F
where
- F: FnOnce($($ty,)* $last,) -> Fut + Clone + Send + 'static,
+ F: FnOnce($($ty,)* $last,) -> Fut + Clone + Send + Sync + 'static,
Fut: Future<Output = Res> + Send,
S: Send + Sync + 'static,
Res: IntoResponse,
@@ -257,7 +257,7 @@ mod private {
impl<T, S> Handler<private::IntoResponseHandler, S> for T
where
- T: IntoResponse + Clone + Send + 'static,
+ T: IntoResponse + Clone + Send + Sync + 'static,
{
type Future = std::future::Ready<Response>;
@@ -302,7 +302,7 @@ where
impl<H, S, T, L> Handler<T, S> for Layered<L, H, T, S>
where
- L: Layer<HandlerService<H, T, S>> + Clone + Send + 'static,
+ L: Layer<HandlerService<H, T, S>> + Clone + Send + Sync + 'static,
H: Handler<T, S>,
L::Service: Service<Request, Error = Infallible> + Clone + Send + 'static,
<L::Service as Service<Request>>::Response: IntoResponse,
diff --git a/axum/src/lib.rs b/axum/src/lib.rs
index 64d4a6a2..27b87e90 100644
--- a/axum/src/lib.rs
+++ b/axum/src/lib.rs
@@ -463,6 +463,7 @@
#[macro_use]
pub(crate) mod macros;
+mod box_clone_service;
mod boxed;
mod extension;
#[cfg(feature = "form")]
diff --git a/axum/src/middleware/from_fn.rs b/axum/src/middleware/from_fn.rs
index f0f47611..e34fd058 100644
--- a/axum/src/middleware/from_fn.rs
+++ b/axum/src/middleware/from_fn.rs
@@ -1,3 +1,4 @@
+use crate::box_clone_service::BoxCloneService;
use crate::response::{IntoResponse, Response};
use axum_core::extract::{FromRequest, FromRequestParts, Request};
use futures_util::future::BoxFuture;
@@ -10,7 +11,7 @@ use std::{
pin::Pin,
task::{Context, Poll},
};
-use tower::{util::BoxCloneService, ServiceBuilder};
+use tower::ServiceBuilder;
use tower_layer::Layer;
use tower_service::Service;
@@ -260,6 +261,7 @@ macro_rules! impl_service {
I: Service<Request, Error = Infallible>
+ Clone
+ Send
+ + Sync
+ 'static,
I::Response: IntoResponse,
I::Future: Send + 'static,
@@ -298,7 +300,7 @@ macro_rules! impl_service {
};
let inner = ServiceBuilder::new()
- .boxed_clone()
+ .layer_fn(BoxCloneService::new)
.map_response(IntoResponse::into_response)
.service(ready_inner);
let next = Next { inner };
diff --git a/axum/src/routing/method_routing.rs b/axum/src/routing/method_routing.rs
index 1eb6075b..8c50eccf 100644
--- a/axum/src/routing/method_routing.rs
+++ b/axum/src/routing/method_routing.rs
@@ -78,7 +78,7 @@ macro_rules! top_level_service_fn {
$(#[$m])+
pub fn $name<T, S>(svc: T) -> MethodRouter<S, T::Error>
where
- T: Service<Request> + Clone + Send + 'static,
+ T: Service<Request> + Clone + Send + Sync + 'static,
T::Response: IntoResponse + 'static,
T::Future: Send + 'static,
S: Clone,
@@ -210,6 +210,7 @@ macro_rules! chained_service_fn {
T: Service<Request, Error = E>
+ Clone
+ Send
+ + Sync
+ 'static,
T::Response: IntoResponse + 'static,
T::Future: Send + 'static,
@@ -312,7 +313,7 @@ top_level_service_fn!(trace_service, TRACE);
/// ```
pub fn on_service<T, S>(filter: MethodFilter, svc: T) -> MethodRouter<S, T::Error>
where
- T: Service<Request> + Clone + Send + 'static,
+ T: Service<Request> + Clone + Send + Sync + 'static,
T::Response: IntoResponse + 'static,
T::Future: Send + 'static,
S: Clone,
@@ -371,7 +372,7 @@ where
/// ```
pub fn any_service<T, S>(svc: T) -> MethodRouter<S, T::Error>
where
- T: Service<Request> + Clone + Send + 'static,
+ T: Service<Request> + Clone + Send + Sync + 'static,
T::Response: IntoResponse + 'static,
T::Future: Send + 'static,
S: Clone,
@@ -736,7 +737,7 @@ where
#[track_caller]
pub fn on_service<T>(self, filter: MethodFilter, svc: T) -> Self
where
- T: Service<Request, Error = E> + Clone + Send + 'static,
+ T: Service<Request, Error = E> + Clone + Send + Sync + 'static,
T::Response: IntoResponse + 'static,
T::Future: Send + 'static,
{
@@ -868,7 +869,7 @@ where
#[doc = include_str!("../docs/method_routing/fallback.md")]
pub fn fallback_service<T>(mut self, svc: T) -> Self
where
- T: Service<Request, Error = E> + Clone + Send + 'static,
+ T: Service<Request, Error = E> + Clone + Send + Sync + 'static,
T::Response: IntoResponse + 'static,
T::Future: Send + 'static,
{
@@ -879,8 +880,8 @@ where
#[doc = include_str!("../docs/method_routing/layer.md")]
pub fn layer<L, NewError>(self, layer: L) -> MethodRouter<S, NewError>
where
- L: Layer<Route<E>> + Clone + Send + 'static,
- L::Service: Service<Request> + Clone + Send + 'static,
+ L: Layer<Route<E>> + Clone + Send + Sync + 'static,
+ L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<NewError> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
@@ -908,8 +909,8 @@ where
#[track_caller]
pub fn route_layer<L>(mut self, layer: L) -> MethodRouter<S, E>
where
- L: Layer<Route<E>> + Clone + Send + 'static,
- L::Service: Service<Request, Error = E> + Clone + Send + 'static,
+ L: Layer<Route<E>> + Clone + Send + Sync + 'static,
+ L::Service: Service<Request, Error = E> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
E: 'static,
@@ -1151,7 +1152,7 @@ where
where
S: 'static,
E: 'static,
- F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + 'static,
+ F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + Sync + 'static,
E2: 'static,
{
match self {
diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs
index dc6ca815..4bd8b28b 100644
--- a/axum/src/routing/mod.rs
+++ b/axum/src/routing/mod.rs
@@ -165,7 +165,7 @@ where
#[doc = include_str!("../docs/routing/route_service.md")]
pub fn route_service<T>(self, path: &str, service: T) -> Self
where
- T: Service<Request, Error = Infallible> + Clone + Send + 'static,
+ T: Service<Request, Error = Infallible> + Clone + Send + Sync + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
@@ -211,7 +211,7 @@ where
#[track_caller]
pub fn nest_service<T>(self, path: &str, service: T) -> Self
where
- T: Service<Request, Error = Infallible> + Clone + Send + 'static,
+ T: Service<Request, Error = Infallible> + Clone + Send + Sync + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
@@ -275,8 +275,8 @@ where
#[doc = include_str!("../docs/routing/layer.md")]
pub fn layer<L>(self, layer: L) -> Router<S>
where
- L: Layer<Route> + Clone + Send + 'static,
- L::Service: Service<Request> + Clone + Send + 'static,
+ L: Layer<Route> + Clone + Send + Sync + 'static,
+ L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
@@ -293,8 +293,8 @@ where
#[track_caller]
pub fn route_layer<L>(self, layer: L) -> Self
where
- L: Layer<Route> + Clone + Send + 'static,
- L::Service: Service<Request> + Clone + Send + 'static,
+ L: Layer<Route> + Clone + Send + Sync + 'static,
+ L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
@@ -331,7 +331,7 @@ where
/// See [`Router::fallback`] for more details.
pub fn fallback_service<T>(self, service: T) -> Self
where
- T: Service<Request, Error = Infallible> + Clone + Send + 'static,
+ T: Service<Request, Error = Infallible> + Clone + Send + Sync + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
@@ -638,7 +638,7 @@ where
where
S: 'static,
E: 'static,
- F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + 'static,
+ F: FnOnce(Route<E>) -> Route<E2> + Clone + Send + Sync + 'static,
E2: 'static,
{
match self {
@@ -701,8 +701,8 @@ where
{
fn layer<L>(self, layer: L) -> Endpoint<S>
where
- L: Layer<Route> + Clone + Send + 'static,
- L::Service: Service<Request> + Clone + Send + 'static,
+ L: Layer<Route> + Clone + Send + Sync + 'static,
+ L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
diff --git a/axum/src/routing/path_router.rs b/axum/src/routing/path_router.rs
index e132f1dc..6a7d3cee 100644
--- a/axum/src/routing/path_router.rs
+++ b/axum/src/routing/path_router.rs
@@ -85,7 +85,7 @@ where
service: T,
) -> Result<(), Cow<'static, str>>
where
- T: Service<Request, Error = Infallible> + Clone + Send + 'static,
+ T: Service<Request, Error = Infallible> + Clone + Send + Sync + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
@@ -201,7 +201,7 @@ where
svc: T,
) -> Result<(), Cow<'static, str>>
where
- T: Service<Request, Error = Infallible> + Clone + Send + 'static,
+ T: Service<Request, Error = Infallible> + Clone + Send + Sync + 'static,
T::Response: IntoResponse,
T::Future: Send + 'static,
{
@@ -236,8 +236,8 @@ where
pub(super) fn layer<L>(self, layer: L) -> PathRouter<S, IS_FALLBACK>
where
- L: Layer<Route> + Clone + Send + 'static,
- L::Service: Service<Request> + Clone + Send + 'static,
+ L: Layer<Route> + Clone + Send + Sync + 'static,
+ L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
@@ -261,8 +261,8 @@ where
#[track_caller]
pub(super) fn route_layer<L>(self, layer: L) -> Self
where
- L: Layer<Route> + Clone + Send + 'static,
- L::Service: Service<Request> + Clone + Send + 'static,
+ L: Layer<Route> + Clone + Send + Sync + 'static,
+ L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
diff --git a/axum/src/routing/route.rs b/axum/src/routing/route.rs
index 242e25f3..71349ba6 100644
--- a/axum/src/routing/route.rs
+++ b/axum/src/routing/route.rs
@@ -1,5 +1,6 @@
use crate::{
body::{Body, HttpBody},
+ box_clone_service::BoxCloneService,
response::Response,
util::AxumMutex,
};
@@ -18,7 +19,7 @@ use std::{
task::{Context, Poll},
};
use tower::{
- util::{BoxCloneService, MapErrLayer, MapRequestLayer, MapResponseLayer, Oneshot},
+ util::{MapErrLayer, MapRequestLayer, MapResponseLayer, Oneshot},
ServiceExt,
};
use tower_layer::Layer;
@@ -33,7 +34,7 @@ pub struct Route<E = Infallible>(AxumMutex<BoxCloneService<Request, Response, E>
impl<E> Route<E> {
pub(crate) fn new<T>(svc: T) -> Self
where
- T: Service<Request, Error = E> + Clone + Send + 'static,
+ T: Service<Request, Error = E> + Clone + Send + Sync + 'static,
T::Response: IntoResponse + 'static,
T::Future: Send + 'static,
{
@@ -52,7 +53,7 @@ impl<E> Route<E> {
pub(crate) fn layer<L, NewError>(self, layer: L) -> Route<NewError>
where
L: Layer<Route<E>> + Clone + Send + 'static,
- L::Service: Service<Request> + Clone + Send + 'static,
+ L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<NewError> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
diff --git a/clippy.toml b/clippy.toml
new file mode 100644
index 00000000..62530998
--- /dev/null
+++ b/clippy.toml
@@ -0,0 +1,3 @@
+disallowed-types = [
+ { path = "tower::util::BoxCloneService", reason = "Use our internal BoxCloneService which is Sync" },
+]