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

Make service builder handler setters more flexible (#2442)



* Add generic parameter to the handler setter

* Constrain Pl::Service in Upgrade rather than S

---------

Co-authored-by: default avatarMatteo Bigoi <1781140+crisidev@users.noreply.github.com>
parent a737694f
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -129,14 +129,14 @@ class ServerServiceGeneratorV2(
                /// ## let app: $serviceName<#{SmithyHttpServer}::routing::Route<#{SmithyHttp}::body::SdkBody>> = app;
                /// ```
                ///
                pub fn $fieldName<HandlerType, Extensions>(self, handler: HandlerType) -> Self
                pub fn $fieldName<HandlerType, HandlerExtractors, ServiceExtractors>(self, handler: HandlerType) -> Self
                where
                    HandlerType: #{SmithyHttpServer}::operation::Handler<crate::operation_shape::$structName, Extensions>,
                    HandlerType: #{SmithyHttpServer}::operation::Handler<crate::operation_shape::$structName, HandlerExtractors>,
                    #{SmithyHttpServer}::operation::Operation<#{SmithyHttpServer}::operation::IntoService<crate::operation_shape::$structName, HandlerType>>:
                        #{SmithyHttpServer}::operation::Upgradable<
                            #{Protocol},
                            crate::operation_shape::$structName,
                            Extensions,
                            ServiceExtractors,
                            $builderBodyGenericTypeName,
                            $builderPluginGenericTypeName,
                        >
@@ -151,12 +151,12 @@ class ServerServiceGeneratorV2(
                /// [`$structName`](crate::operation_shape::$structName) using either
                /// [`OperationShape::from_handler`](#{SmithyHttpServer}::operation::OperationShapeExt::from_handler) or
                /// [`OperationShape::from_service`](#{SmithyHttpServer}::operation::OperationShapeExt::from_service).
                pub fn ${fieldName}_operation<Operation, Extensions>(mut self, operation: Operation) -> Self
                pub fn ${fieldName}_operation<Operation, Extractors>(mut self, operation: Operation) -> Self
                where
                    Operation: #{SmithyHttpServer}::operation::Upgradable<
                        #{Protocol},
                        crate::operation_shape::$structName,
                        Extensions,
                        Extractors,
                        $builderBodyGenericTypeName,
                        $builderPluginGenericTypeName,
                    >
+2 −1
Original line number Diff line number Diff line
@@ -239,7 +239,8 @@ where
    Exts: FromParts<P>,

    // The signature of the inner service is correct
    S: Service<(Op::Input, Exts), Response = Op::Output, Error = OperationError<Op::Error, PollError>> + Clone,
    Pl::Service:
        Service<(Op::Input, Exts), Response = Op::Output, Error = OperationError<Op::Error, PollError>> + Clone,

    // The plugin takes this operation as input
    Pl: Plugin<P, Op, S, L>,