Skip to content

Commit

Permalink
Make service builder handler setters more flexible (#2442)
Browse files Browse the repository at this point in the history
* Add generic parameter to the handler setter

* Constrain Pl::Service in Upgrade rather than S

---------

Co-authored-by: Matteo Bigoi <[email protected]>
  • Loading branch information
hlbarber and crisidev authored Mar 22, 2023
1 parent a737694 commit abbf78f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
>
Expand All @@ -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,
>
Expand Down
3 changes: 2 additions & 1 deletion rust-runtime/aws-smithy-http-server/src/operation/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down

0 comments on commit abbf78f

Please sign in to comment.