Unverified Commit 6b3e3112 authored by Harry Barber's avatar Harry Barber Committed by GitHub
Browse files

Add boxed method to service builder (#1840)

parent 425d91b3
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ class ServerServiceGeneratorV2(
        rustTemplate(
            """
            ##[derive(Clone)]
            pub struct $serviceName<S> {
            pub struct $serviceName<S = #{SmithyHttpServer}::routing::Route> {
                router: #{SmithyHttpServer}::routers::RoutingService<#{Router}<S>, #{Protocol}>,
            }

@@ -321,6 +321,21 @@ class ServerServiceGeneratorV2(
                        router: self.router.map(|s| s.layer(layer))
                    }
                }

                /// Applies [`Route::new`](#{SmithyHttpServer}::routing::Route::new) to all routes.
                ///
                /// This has the effect of erasing all types accumulated via [`layer`].
                pub fn boxed<B>(self) -> $serviceName<#{SmithyHttpServer}::routing::Route<B>>
                where
                    S: #{Tower}::Service<
                        #{Http}::Request<B>,
                        Response = #{Http}::Response<#{SmithyHttpServer}::body::BoxBody>,
                        Error = std::convert::Infallible>,
                    S: Clone + Send + 'static,
                    S::Future: Send + 'static,
                {
                    self.layer(&#{Tower}::layer::layer_fn(#{SmithyHttpServer}::routing::Route::new))
                }
            }

            impl<B, RespB, S> #{Tower}::Service<#{Http}::Request<B>> for $serviceName<S>