Skip to content

Commit abbf78f

Browse files
hlbarbercrisidev
andauthored
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: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
1 parent a737694 commit abbf78f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ class ServerServiceGeneratorV2(
129129
/// ## let app: $serviceName<#{SmithyHttpServer}::routing::Route<#{SmithyHttp}::body::SdkBody>> = app;
130130
/// ```
131131
///
132-
pub fn $fieldName<HandlerType, Extensions>(self, handler: HandlerType) -> Self
132+
pub fn $fieldName<HandlerType, HandlerExtractors, ServiceExtractors>(self, handler: HandlerType) -> Self
133133
where
134-
HandlerType: #{SmithyHttpServer}::operation::Handler<crate::operation_shape::$structName, Extensions>,
134+
HandlerType: #{SmithyHttpServer}::operation::Handler<crate::operation_shape::$structName, HandlerExtractors>,
135135
#{SmithyHttpServer}::operation::Operation<#{SmithyHttpServer}::operation::IntoService<crate::operation_shape::$structName, HandlerType>>:
136136
#{SmithyHttpServer}::operation::Upgradable<
137137
#{Protocol},
138138
crate::operation_shape::$structName,
139-
Extensions,
139+
ServiceExtractors,
140140
$builderBodyGenericTypeName,
141141
$builderPluginGenericTypeName,
142142
>
@@ -151,12 +151,12 @@ class ServerServiceGeneratorV2(
151151
/// [`$structName`](crate::operation_shape::$structName) using either
152152
/// [`OperationShape::from_handler`](#{SmithyHttpServer}::operation::OperationShapeExt::from_handler) or
153153
/// [`OperationShape::from_service`](#{SmithyHttpServer}::operation::OperationShapeExt::from_service).
154-
pub fn ${fieldName}_operation<Operation, Extensions>(mut self, operation: Operation) -> Self
154+
pub fn ${fieldName}_operation<Operation, Extractors>(mut self, operation: Operation) -> Self
155155
where
156156
Operation: #{SmithyHttpServer}::operation::Upgradable<
157157
#{Protocol},
158158
crate::operation_shape::$structName,
159-
Extensions,
159+
Extractors,
160160
$builderBodyGenericTypeName,
161161
$builderPluginGenericTypeName,
162162
>

rust-runtime/aws-smithy-http-server/src/operation/upgrade.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ where
239239
Exts: FromParts<P>,
240240

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

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

0 commit comments

Comments
 (0)