Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405

Files changed:

tmp-codegen-diff/codegen-server-test/simple-http0x/rust-server-codegen/src/operation_shape.rs

@@ -0,1 +0,38 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(missing_docs)] // documentation missing in model
           3  +
pub struct Operation;
           4  +
           5  +
impl ::aws_smithy_legacy_http_server::operation::OperationShape for Operation {
           6  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
           7  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
           8  +
            "com.amazonaws.simple#Operation",
           9  +
            "com.amazonaws.simple",
          10  +
            "Operation",
          11  +
        );
          12  +
          13  +
    type Input = crate::input::OperationInput;
          14  +
    type Output = crate::output::OperationOutput;
          15  +
    type Error = std::convert::Infallible;
          16  +
}
          17  +
          18  +
impl ::aws_smithy_legacy_http_server::instrumentation::sensitivity::Sensitivity for Operation {
          19  +
    type RequestFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt<
          20  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          21  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::uri::MakeUri<
          22  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          23  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          24  +
        >,
          25  +
    >;
          26  +
    type ResponseFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt<
          27  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          28  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          29  +
    >;
          30  +
          31  +
    fn request_fmt() -> Self::RequestFmt {
          32  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt::new()
          33  +
    }
          34  +
          35  +
    fn response_fmt() -> Self::ResponseFmt {
          36  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt::new()
          37  +
    }
          38  +
}

tmp-codegen-diff/codegen-server-test/simple-http0x/rust-server-codegen/src/output.rs

@@ -0,1 +0,51 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(missing_docs)] // documentation missing in model
           3  +
#[derive(
           4  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
           5  +
)]
           6  +
pub struct OperationOutput {
           7  +
    #[allow(missing_docs)] // documentation missing in model
           8  +
    pub message: ::std::option::Option<::std::string::String>,
           9  +
}
          10  +
impl OperationOutput {
          11  +
    #[allow(missing_docs)] // documentation missing in model
          12  +
    pub fn message(&self) -> ::std::option::Option<&str> {
          13  +
        self.message.as_deref()
          14  +
    }
          15  +
}
          16  +
impl OperationOutput {
          17  +
    /// Creates a new builder-style object to manufacture [`OperationOutput`](crate::output::OperationOutput).
          18  +
    pub fn builder() -> crate::output::operation_output::Builder {
          19  +
        crate::output::operation_output::Builder::default()
          20  +
    }
          21  +
}
          22  +
/// See [`OperationOutput`](crate::output::OperationOutput).
          23  +
pub mod operation_output {
          24  +
          25  +
    impl ::std::convert::From<Builder> for crate::output::OperationOutput {
          26  +
        fn from(builder: Builder) -> Self {
          27  +
            builder.build()
          28  +
        }
          29  +
    }
          30  +
    /// A builder for [`OperationOutput`](crate::output::OperationOutput).
          31  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
          32  +
    pub struct Builder {
          33  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
          34  +
    }
          35  +
    impl Builder {
          36  +
        #[allow(missing_docs)] // documentation missing in model
          37  +
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
          38  +
            self.message = input;
          39  +
            self
          40  +
        }
          41  +
        /// Consumes the builder and constructs a [`OperationOutput`](crate::output::OperationOutput).
          42  +
        pub fn build(self) -> crate::output::OperationOutput {
          43  +
            self.build_enforcing_all_constraints()
          44  +
        }
          45  +
        fn build_enforcing_all_constraints(self) -> crate::output::OperationOutput {
          46  +
            crate::output::OperationOutput {
          47  +
                message: self.message,
          48  +
            }
          49  +
        }
          50  +
    }
          51  +
}

tmp-codegen-diff/codegen-server-test/simple-http0x/rust-server-codegen/src/protocol_serde.rs

@@ -0,1 +0,12 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) mod shape_operation;
           3  +
           4  +
pub(crate) fn or_empty_doc(data: &[u8]) -> &[u8] {
           5  +
    if data.is_empty() {
           6  +
        b"{}"
           7  +
    } else {
           8  +
        data
           9  +
    }
          10  +
}
          11  +
          12  +
pub(crate) mod shape_operation_output;

tmp-codegen-diff/codegen-server-test/simple-http0x/rust-server-codegen/src/protocol_serde/shape_operation.rs

@@ -0,1 +0,112 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_operation_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::OperationInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::operation_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          23  +
        if !bytes.is_empty() {
          24  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          25  +
                &headers,
          26  +
                Some("application/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_operation::de_operation(bytes.as_ref(), input)?;
          29  +
        }
          30  +
        input.build()
          31  +
    })
          32  +
}
          33  +
          34  +
#[allow(clippy::unnecessary_wraps)]
          35  +
pub fn ser_operation_http_response(
          36  +
    #[allow(unused_variables)] output: crate::output::OperationOutput,
          37  +
) -> std::result::Result<
          38  +
    ::aws_smithy_legacy_http_server::response::Response,
          39  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          40  +
> {
          41  +
    Ok({
          42  +
        #[allow(unused_mut)]
          43  +
        let mut builder = ::http::Response::builder();
          44  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          45  +
            builder,
          46  +
            ::http::header::CONTENT_TYPE,
          47  +
            "application/json",
          48  +
        );
          49  +
        let http_status: u16 = 200;
          50  +
        builder = builder.status(http_status);
          51  +
        let payload =
          52  +
            crate::protocol_serde::shape_operation_output::ser_operation_output_output_output(
          53  +
                &output,
          54  +
            )?;
          55  +
        let content_length = payload.len();
          56  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http::header::CONTENT_LENGTH,
          59  +
            content_length,
          60  +
        );
          61  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          62  +
        builder.body(body)?
          63  +
    })
          64  +
}
          65  +
          66  +
pub(crate) fn de_operation(
          67  +
    value: &[u8],
          68  +
    mut builder: crate::input::operation_input::Builder,
          69  +
) -> ::std::result::Result<
          70  +
    crate::input::operation_input::Builder,
          71  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          72  +
> {
          73  +
    let mut tokens_owned =
          74  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
          75  +
            .peekable();
          76  +
    let tokens = &mut tokens_owned;
          77  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
          78  +
    loop {
          79  +
        match tokens.next().transpose()? {
          80  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          81  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          82  +
                match key.to_unescaped()?.as_ref() {
          83  +
                    "message" => {
          84  +
                        builder = builder.set_message(
          85  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          86  +
                                tokens.next(),
          87  +
                            )?
          88  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          89  +
                            .transpose()?,
          90  +
                        );
          91  +
                    }
          92  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          93  +
                }
          94  +
            }
          95  +
            other => {
          96  +
                return Err(
          97  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
          98  +
                        "expected object key or end object, found: {other:?}"
          99  +
                    )),
         100  +
                )
         101  +
            }
         102  +
        }
         103  +
    }
         104  +
    if tokens.next().is_some() {
         105  +
        return Err(
         106  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         107  +
                "found more JSON tokens after completing parsing",
         108  +
            ),
         109  +
        );
         110  +
    }
         111  +
    Ok(builder)
         112  +
}

tmp-codegen-diff/codegen-server-test/simple-http0x/rust-server-codegen/src/protocol_serde/shape_operation_output.rs

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_operation_output_output_output(
           3  +
    value: &crate::output::OperationOutput,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_operation_output::ser_operation_output_output(&mut object, value)?;
           8  +
    object.finish();
           9  +
    Ok(out)
          10  +
}
          11  +
          12  +
pub fn ser_operation_output_output(
          13  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          14  +
    input: &crate::output::OperationOutput,
          15  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          16  +
    if let Some(var_1) = &input.message {
          17  +
        object.key("message").string(var_1.as_str());
          18  +
    }
          19  +
    Ok(())
          20  +
}

tmp-codegen-diff/codegen-server-test/simple-http0x/rust-server-codegen/src/service.rs

@@ -0,1 +0,728 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/// The service builder for [`SimpleService`].
           3  +
///
           4  +
/// Constructed via [`SimpleService::builder`].
           5  +
pub struct SimpleServiceBuilder<Body, L, HttpPl, ModelPl> {
           6  +
    operation: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
           7  +
    layer: L,
           8  +
    http_plugin: HttpPl,
           9  +
    model_plugin: ModelPl,
          10  +
}
          11  +
          12  +
impl<Body, L, HttpPl, ModelPl> SimpleServiceBuilder<Body, L, HttpPl, ModelPl> {
          13  +
    /// Sets the [`Operation`](crate::operation_shape::Operation) operation.
          14  +
    ///
          15  +
    /// This should be an async function satisfying the [`Handler`](::aws_smithy_legacy_http_server::operation::Handler) trait.
          16  +
    /// See the [operation module documentation](::aws_smithy_legacy_http_server::operation) for more information.
          17  +
    ///
          18  +
    /// # Example
          19  +
    ///
          20  +
    /// ```no_run
          21  +
    /// use simple_http0x::{SimpleService, SimpleServiceConfig};
          22  +
    ///
          23  +
    /// use simple_http0x::{input, output};
          24  +
    ///
          25  +
    /// async fn handler(input: input::OperationInput) -> output::OperationOutput {
          26  +
    ///     todo!()
          27  +
    /// }
          28  +
    ///
          29  +
    /// let config = SimpleServiceConfig::builder().build();
          30  +
    /// let app = SimpleService::builder(config)
          31  +
    ///     .operation(handler)
          32  +
    ///     /* Set other handlers */
          33  +
    ///     .build()
          34  +
    ///     .unwrap();
          35  +
    /// # let app: SimpleService<::aws_smithy_legacy_http_server::routing::RoutingService<::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<::aws_smithy_legacy_http_server::routing::Route>, ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>> = app;
          36  +
    /// ```
          37  +
    ///
          38  +
                    pub fn operation<HandlerType, HandlerExtractors, UpgradeExtractors>(self, handler: HandlerType) -> Self
          39  +
                    where
          40  +
                        HandlerType: ::aws_smithy_legacy_http_server::operation::Handler<crate::operation_shape::Operation, HandlerExtractors>,
          41  +
          42  +
                        ModelPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
          43  +
                            SimpleService<L>,
          44  +
                            crate::operation_shape::Operation,
          45  +
                            ::aws_smithy_legacy_http_server::operation::IntoService<crate::operation_shape::Operation, HandlerType>
          46  +
                        >,
          47  +
                        ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_legacy_http_server::plugin::Plugin<
          48  +
                            SimpleService<L>,
          49  +
                            crate::operation_shape::Operation,
          50  +
                            ModelPl::Output
          51  +
                        >,
          52  +
                        HttpPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
          53  +
                            SimpleService<L>,
          54  +
                            crate::operation_shape::Operation,
          55  +
                            <
          56  +
                                ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
          57  +
                                as ::aws_smithy_legacy_http_server::plugin::Plugin<
          58  +
                                    SimpleService<L>,
          59  +
                                    crate::operation_shape::Operation,
          60  +
                                    ModelPl::Output
          61  +
                                >
          62  +
                            >::Output
          63  +
                        >,
          64  +
          65  +
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_legacy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
          66  +
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
          67  +
          68  +
                    {
          69  +
        use ::aws_smithy_legacy_http_server::operation::OperationShapeExt;
          70  +
        use ::aws_smithy_legacy_http_server::plugin::Plugin;
          71  +
        let svc = crate::operation_shape::Operation::from_handler(handler);
          72  +
        let svc = self.model_plugin.apply(svc);
          73  +
        let svc =
          74  +
            ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
          75  +
                .apply(svc);
          76  +
        let svc = self.http_plugin.apply(svc);
          77  +
        self.operation_custom(svc)
          78  +
    }
          79  +
          80  +
    /// Sets the [`Operation`](crate::operation_shape::Operation) operation.
          81  +
    ///
          82  +
    /// This should be an async function satisfying the [`Handler`](::aws_smithy_legacy_http_server::operation::Handler) trait.
          83  +
    /// See the [operation module documentation](::aws_smithy_legacy_http_server::operation) for more information.
          84  +
    ///
          85  +
    /// # Example
          86  +
    ///
          87  +
    /// ```no_run
          88  +
    /// use simple_http0x::{SimpleService, SimpleServiceConfig};
          89  +
    ///
          90  +
    /// use simple_http0x::{input, output};
          91  +
    ///
          92  +
    /// async fn handler(input: input::OperationInput) -> Result<output::OperationOutput, std::convert::Infallible> {
          93  +
    ///     todo!()
          94  +
    /// }
          95  +
    ///
          96  +
    /// let config = SimpleServiceConfig::builder().build();
          97  +
    /// let svc = ::tower::util::service_fn(handler);
          98  +
    /// let app = SimpleService::builder(config)
          99  +
    ///     .operation_service(svc)
         100  +
    ///     /* Set other handlers */
         101  +
    ///     .build()
         102  +
    ///     .unwrap();
         103  +
    /// # let app: SimpleService<::aws_smithy_legacy_http_server::routing::RoutingService<::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<::aws_smithy_legacy_http_server::routing::Route>, ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>> = app;
         104  +
    /// ```
         105  +
    ///
         106  +
                    pub fn operation_service<S, ServiceExtractors, UpgradeExtractors>(self, service: S) -> Self
         107  +
                    where
         108  +
                        S: ::aws_smithy_legacy_http_server::operation::OperationService<crate::operation_shape::Operation, ServiceExtractors>,
         109  +
         110  +
                        ModelPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
         111  +
                            SimpleService<L>,
         112  +
                            crate::operation_shape::Operation,
         113  +
                            ::aws_smithy_legacy_http_server::operation::Normalize<crate::operation_shape::Operation, S>
         114  +
                        >,
         115  +
                        ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_legacy_http_server::plugin::Plugin<
         116  +
                            SimpleService<L>,
         117  +
                            crate::operation_shape::Operation,
         118  +
                            ModelPl::Output
         119  +
                        >,
         120  +
                        HttpPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
         121  +
                            SimpleService<L>,
         122  +
                            crate::operation_shape::Operation,
         123  +
                            <
         124  +
                                ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
         125  +
                                as ::aws_smithy_legacy_http_server::plugin::Plugin<
         126  +
                                    SimpleService<L>,
         127  +
                                    crate::operation_shape::Operation,
         128  +
                                    ModelPl::Output
         129  +
                                >
         130  +
                            >::Output
         131  +
                        >,
         132  +
         133  +
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_legacy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
         134  +
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
         135  +
         136  +
                    {
         137  +
        use ::aws_smithy_legacy_http_server::operation::OperationShapeExt;
         138  +
        use ::aws_smithy_legacy_http_server::plugin::Plugin;
         139  +
        let svc = crate::operation_shape::Operation::from_service(service);
         140  +
        let svc = self.model_plugin.apply(svc);
         141  +
        let svc =
         142  +
            ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
         143  +
                .apply(svc);
         144  +
        let svc = self.http_plugin.apply(svc);
         145  +
        self.operation_custom(svc)
         146  +
    }
         147  +
         148  +
    /// Sets the [`Operation`](crate::operation_shape::Operation) to a custom [`Service`](tower::Service).
         149  +
    /// not constrained by the Smithy contract.
         150  +
    fn operation_custom<S>(mut self, svc: S) -> Self
         151  +
    where
         152  +
        S: ::tower::Service<
         153  +
                ::http::Request<Body>,
         154  +
                Response = ::http::Response<::aws_smithy_legacy_http_server::body::BoxBody>,
         155  +
                Error = ::std::convert::Infallible,
         156  +
            > + Clone
         157  +
            + Send
         158  +
            + 'static,
         159  +
        S::Future: Send + 'static,
         160  +
    {
         161  +
        self.operation = Some(::aws_smithy_legacy_http_server::routing::Route::new(svc));
         162  +
        self
         163  +
    }
         164  +
}
         165  +
         166  +
impl<Body, L, HttpPl, ModelPl> SimpleServiceBuilder<Body, L, HttpPl, ModelPl> {
         167  +
    /// Constructs a [`SimpleService`] from the arguments provided to the builder.
         168  +
    ///
         169  +
    /// Forgetting to register a handler for one or more operations will result in an error.
         170  +
    ///
         171  +
    /// Check out [`SimpleServiceBuilder::build_unchecked`] if you'd prefer the service to return status code 500 when an
         172  +
    /// unspecified route is requested.
         173  +
    pub fn build(
         174  +
        self,
         175  +
    ) -> ::std::result::Result<
         176  +
        SimpleService<
         177  +
            ::aws_smithy_legacy_http_server::routing::RoutingService<
         178  +
                ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<L::Service>,
         179  +
                ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
         180  +
            >,
         181  +
        >,
         182  +
        MissingOperationsError,
         183  +
    >
         184  +
    where
         185  +
        L: ::tower::Layer<::aws_smithy_legacy_http_server::routing::Route<Body>>,
         186  +
    {
         187  +
        let router = {
         188  +
            use ::aws_smithy_legacy_http_server::operation::OperationShape;
         189  +
            let mut missing_operation_names = std::collections::HashMap::new();
         190  +
            if self.operation.is_none() {
         191  +
                missing_operation_names
         192  +
                    .insert(crate::operation_shape::Operation::ID, ".operation()");
         193  +
            }
         194  +
            if !missing_operation_names.is_empty() {
         195  +
                return Err(MissingOperationsError {
         196  +
                    operation_names2setter_methods: missing_operation_names,
         197  +
                });
         198  +
            }
         199  +
            let unexpected_error_msg = "this should never panic since we are supposed to check beforehand that a handler has been registered for this operation; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues";
         200  +
         201  +
            ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter::from_iter([(
         202  +
                request_specs::operation(),
         203  +
                self.operation.expect(unexpected_error_msg),
         204  +
            )])
         205  +
        };
         206  +
        let svc = ::aws_smithy_legacy_http_server::routing::RoutingService::new(router);
         207  +
        let svc = svc.map(|s| s.layer(self.layer));
         208  +
        Ok(SimpleService { svc })
         209  +
    }
         210  +
         211  +
    /// Constructs a [`SimpleService`] from the arguments provided to the builder.
         212  +
    /// Operations without a handler default to returning 500 Internal Server Error to the caller.
         213  +
    ///
         214  +
    /// Check out [`SimpleServiceBuilder::build`] if you'd prefer the builder to fail if one or more operations do
         215  +
    /// not have a registered handler.
         216  +
    pub fn build_unchecked(self) -> SimpleService<L::Service>
         217  +
    where
         218  +
        Body: Send + 'static,
         219  +
        L: ::tower::Layer<
         220  +
            ::aws_smithy_legacy_http_server::routing::RoutingService<
         221  +
                ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<
         222  +
                    ::aws_smithy_legacy_http_server::routing::Route<Body>,
         223  +
                >,
         224  +
                ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
         225  +
            >,
         226  +
        >,
         227  +
    {
         228  +
        let router =
         229  +
            ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter::from_iter([(
         230  +
                request_specs::operation(),
         231  +
                self.operation.unwrap_or_else(|| {
         232  +
                    let svc = ::aws_smithy_legacy_http_server::operation::MissingFailure::<
         233  +
                        ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
         234  +
                    >::default();
         235  +
                    ::aws_smithy_legacy_http_server::routing::Route::new(svc)
         236  +
                }),
         237  +
            )]);
         238  +
        let svc = self
         239  +
            .layer
         240  +
            .layer(::aws_smithy_legacy_http_server::routing::RoutingService::new(router));
         241  +
        SimpleService { svc }
         242  +
    }
         243  +
}
         244  +
         245  +
/// The error encountered when calling the [`SimpleServiceBuilder::build`] method if one or more operation handlers are not
         246  +
/// specified.
         247  +
#[derive(Debug)]
         248  +
pub struct MissingOperationsError {
         249  +
    operation_names2setter_methods:
         250  +
        std::collections::HashMap<::aws_smithy_legacy_http_server::shape_id::ShapeId, &'static str>,
         251  +
}
         252  +
         253  +
impl std::fmt::Display for MissingOperationsError {
         254  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         255  +
        write!(
         256  +
            f,
         257  +
            "You must specify a handler for all operations attached to `SimpleService`.\n\
         258  +
                            We are missing handlers for the following operations:\n",
         259  +
        )?;
         260  +
        for operation_name in self.operation_names2setter_methods.keys() {
         261  +
            writeln!(f, "- {}", operation_name.absolute())?;
         262  +
        }
         263  +
         264  +
        writeln!(f, "\nUse the dedicated methods on `SimpleServiceBuilder` to register the missing handlers:")?;
         265  +
        for setter_name in self.operation_names2setter_methods.values() {
         266  +
            writeln!(f, "- {}", setter_name)?;
         267  +
        }
         268  +
        Ok(())
         269  +
    }
         270  +
}
         271  +
         272  +
impl std::error::Error for MissingOperationsError {}
         273  +
         274  +
mod request_specs {
         275  +
    pub(super) fn operation() -> ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec
         276  +
    {
         277  +
        ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec::new(
         278  +
                    ::http::Method::POST,
         279  +
                    ::aws_smithy_legacy_http_server::routing::request_spec::UriSpec::new(
         280  +
                        ::aws_smithy_legacy_http_server::routing::request_spec::PathAndQuerySpec::new(
         281  +
                            ::aws_smithy_legacy_http_server::routing::request_spec::PathSpec::from_vector_unchecked(vec![
         282  +
    ::aws_smithy_legacy_http_server::routing::request_spec::PathSegment::Literal(String::from("operation")),
         283  +
]),
         284  +
                            ::aws_smithy_legacy_http_server::routing::request_spec::QuerySpec::from_vector_unchecked(vec![
         285  +
])
         286  +
                        )
         287  +
                    ),
         288  +
                )
         289  +
    }
         290  +
}
         291  +
         292  +
#[allow(missing_docs)] // documentation missing in model
         293  +
///
         294  +
/// See the [root](crate) documentation for more information.
         295  +
#[derive(Clone)]
         296  +
pub struct SimpleService<
         297  +
    S = ::aws_smithy_legacy_http_server::routing::RoutingService<
         298  +
        ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<
         299  +
            ::aws_smithy_legacy_http_server::routing::Route<
         300  +
                ::aws_smithy_legacy_http_server::body::BoxBody,
         301  +
            >,
         302  +
        >,
         303  +
        ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
         304  +
    >,
         305  +
> {
         306  +
    // This is the router wrapped by layers.
         307  +
    svc: S,
         308  +
}
         309  +
         310  +
impl SimpleService<()> {
         311  +
    /// Constructs a builder for [`SimpleService`].
         312  +
    /// You must specify a configuration object holding any plugins and layers that should be applied
         313  +
    /// to the operations in this service.
         314  +
    pub fn builder<
         315  +
        Body,
         316  +
        L,
         317  +
        HttpPl: ::aws_smithy_legacy_http_server::plugin::HttpMarker,
         318  +
        ModelPl: ::aws_smithy_legacy_http_server::plugin::ModelMarker,
         319  +
    >(
         320  +
        config: SimpleServiceConfig<L, HttpPl, ModelPl>,
         321  +
    ) -> SimpleServiceBuilder<Body, L, HttpPl, ModelPl> {
         322  +
        SimpleServiceBuilder {
         323  +
            operation: None,
         324  +
            layer: config.layers,
         325  +
            http_plugin: config.http_plugins,
         326  +
            model_plugin: config.model_plugins,
         327  +
        }
         328  +
    }
         329  +
         330  +
    /// Constructs a builder for [`SimpleService`].
         331  +
    /// You must specify what plugins should be applied to the operations in this service.
         332  +
    ///
         333  +
    /// Use [`SimpleService::builder_without_plugins`] if you don't need to apply plugins.
         334  +
    ///
         335  +
    /// Check out [`HttpPlugins`](::aws_smithy_legacy_http_server::plugin::HttpPlugins) and
         336  +
    /// [`ModelPlugins`](::aws_smithy_legacy_http_server::plugin::ModelPlugins) if you need to apply
         337  +
    /// multiple plugins.
         338  +
    #[deprecated(
         339  +
        since = "0.57.0",
         340  +
        note = "please use the `builder` constructor and register plugins on the `SimpleServiceConfig` object instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
         341  +
    )]
         342  +
    pub fn builder_with_plugins<
         343  +
        Body,
         344  +
        HttpPl: ::aws_smithy_legacy_http_server::plugin::HttpMarker,
         345  +
        ModelPl: ::aws_smithy_legacy_http_server::plugin::ModelMarker,
         346  +
    >(
         347  +
        http_plugin: HttpPl,
         348  +
        model_plugin: ModelPl,
         349  +
    ) -> SimpleServiceBuilder<Body, ::tower::layer::util::Identity, HttpPl, ModelPl> {
         350  +
        SimpleServiceBuilder {
         351  +
            operation: None,
         352  +
            layer: ::tower::layer::util::Identity::new(),
         353  +
            http_plugin,
         354  +
            model_plugin,
         355  +
        }
         356  +
    }
         357  +
         358  +
    /// Constructs a builder for [`SimpleService`].
         359  +
    ///
         360  +
    /// Use [`SimpleService::builder_with_plugins`] if you need to specify plugins.
         361  +
    #[deprecated(
         362  +
        since = "0.57.0",
         363  +
        note = "please use the `builder` constructor instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
         364  +
    )]
         365  +
    pub fn builder_without_plugins<Body>() -> SimpleServiceBuilder<
         366  +
        Body,
         367  +
        ::tower::layer::util::Identity,
         368  +
        ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         369  +
        ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         370  +
    > {
         371  +
        Self::builder_with_plugins(
         372  +
            ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         373  +
            ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         374  +
        )
         375  +
    }
         376  +
}
         377  +
         378  +
impl<S> SimpleService<S> {
         379  +
    /// Converts [`SimpleService`] into a [`MakeService`](tower::make::MakeService).
         380  +
    pub fn into_make_service(
         381  +
        self,
         382  +
    ) -> ::aws_smithy_legacy_http_server::routing::IntoMakeService<Self> {
         383  +
        ::aws_smithy_legacy_http_server::routing::IntoMakeService::new(self)
         384  +
    }
         385  +
         386  +
    /// Converts [`SimpleService`] into a [`MakeService`](tower::make::MakeService) with [`ConnectInfo`](::aws_smithy_legacy_http_server::request::connect_info::ConnectInfo).
         387  +
    pub fn into_make_service_with_connect_info<C>(
         388  +
        self,
         389  +
    ) -> ::aws_smithy_legacy_http_server::routing::IntoMakeServiceWithConnectInfo<Self, C> {
         390  +
        ::aws_smithy_legacy_http_server::routing::IntoMakeServiceWithConnectInfo::new(self)
         391  +
    }
         392  +
}
         393  +
         394  +
impl<S>
         395  +
    SimpleService<
         396  +
        ::aws_smithy_legacy_http_server::routing::RoutingService<
         397  +
            ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<S>,
         398  +
            ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
         399  +
        >,
         400  +
    >
         401  +
{
         402  +
    /// Applies a [`Layer`](::tower::Layer) uniformly to all routes.
         403  +
    #[deprecated(
         404  +
        since = "0.57.0",
         405  +
        note = "please add layers to the `SimpleServiceConfig` object instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
         406  +
    )]
         407  +
    pub fn layer<L>(
         408  +
        self,
         409  +
        layer: &L,
         410  +
    ) -> SimpleService<
         411  +
        ::aws_smithy_legacy_http_server::routing::RoutingService<
         412  +
            ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<L::Service>,
         413  +
            ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
         414  +
        >,
         415  +
    >
         416  +
    where
         417  +
        L: ::tower::Layer<S>,
         418  +
    {
         419  +
        SimpleService {
         420  +
            svc: self.svc.map(|s| s.layer(layer)),
         421  +
        }
         422  +
    }
         423  +
         424  +
    /// Applies [`Route::new`](::aws_smithy_legacy_http_server::routing::Route::new) to all routes.
         425  +
    ///
         426  +
    /// This has the effect of erasing all types accumulated via layers.
         427  +
    pub fn boxed<B>(
         428  +
        self,
         429  +
    ) -> SimpleService<
         430  +
        ::aws_smithy_legacy_http_server::routing::RoutingService<
         431  +
            ::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<
         432  +
                ::aws_smithy_legacy_http_server::routing::Route<B>,
         433  +
            >,
         434  +
            ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
         435  +
        >,
         436  +
    >
         437  +
    where
         438  +
        S: ::tower::Service<
         439  +
            ::http::Request<B>,
         440  +
            Response = ::http::Response<::aws_smithy_legacy_http_server::body::BoxBody>,
         441  +
            Error = std::convert::Infallible,
         442  +
        >,
         443  +
        S: Clone + Send + 'static,
         444  +
        S::Future: Send + 'static,
         445  +
    {
         446  +
        self.layer(&::tower::layer::layer_fn(
         447  +
            ::aws_smithy_legacy_http_server::routing::Route::new,
         448  +
        ))
         449  +
    }
         450  +
}
         451  +
         452  +
impl<S, R> ::tower::Service<R> for SimpleService<S>
         453  +
where
         454  +
    S: ::tower::Service<R>,
         455  +
{
         456  +
    type Response = S::Response;
         457  +
    type Error = S::Error;
         458  +
    type Future = S::Future;
         459  +
         460  +
    fn poll_ready(
         461  +
        &mut self,
         462  +
        cx: &mut std::task::Context,
         463  +
    ) -> std::task::Poll<::std::result::Result<(), Self::Error>> {
         464  +
        self.svc.poll_ready(cx)
         465  +
    }
         466  +
         467  +
    fn call(&mut self, request: R) -> Self::Future {
         468  +
        self.svc.call(request)
         469  +
    }
         470  +
}
         471  +
         472  +
/// An enumeration of all [operations](https://smithy.io/2.0/spec/service-types.html#operation) in SimpleService.
         473  +
#[allow(clippy::enum_variant_names)]
         474  +
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
         475  +
pub enum Operation {
         476  +
    Operation,
         477  +
}
         478  +
         479  +
impl Operation {
         480  +
    /// Returns the [operations](https://smithy.io/2.0/spec/service-types.html#operation) [`ShapeId`](::aws_smithy_legacy_http_server::shape_id::ShapeId).
         481  +
    pub fn shape_id(&self) -> ::aws_smithy_legacy_http_server::shape_id::ShapeId {
         482  +
        match self {
         483  +
            Operation::Operation => ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
         484  +
                "com.amazonaws.simple#Operation",
         485  +
                "com.amazonaws.simple",
         486  +
                "Operation",
         487  +
            ),
         488  +
        }
         489  +
    }
         490  +
}
         491  +
impl<L>
         492  +
    ::aws_smithy_legacy_http_server::service::ContainsOperation<crate::operation_shape::Operation>
         493  +
    for SimpleService<L>
         494  +
{
         495  +
    const VALUE: Operation = Operation::Operation;
         496  +
}
         497  +
         498  +
impl<S> ::aws_smithy_legacy_http_server::service::ServiceShape for SimpleService<S> {
         499  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
         500  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
         501  +
            "com.amazonaws.simple#SimpleService",
         502  +
            "com.amazonaws.simple",
         503  +
            "SimpleService",
         504  +
        );
         505  +
         506  +
    const VERSION: Option<&'static str> = Some("");
         507  +
         508  +
    type Protocol = ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1;
         509  +
         510  +
    type Operations = Operation;
         511  +
}
         512  +
/// Configuration for the [`SimpleService`]. This is the central place where to register and
         513  +
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
         514  +
///
         515  +
/// ```rust,no_run
         516  +
/// # use simple_http0x::SimpleServiceConfig;
         517  +
/// # use ::aws_smithy_legacy_http_server::plugin::IdentityPlugin;
         518  +
/// # use ::tower::layer::util::Identity;
         519  +
/// # let authentication_plugin = IdentityPlugin;
         520  +
/// # let authorization_plugin = IdentityPlugin;
         521  +
/// # let server_request_id_provider_layer = Identity::new();
         522  +
/// let config = SimpleServiceConfig::builder()
         523  +
///     // Layers get executed first...
         524  +
///     .layer(server_request_id_provider_layer)
         525  +
///     // ...then HTTP plugins...
         526  +
///     .http_plugin(authentication_plugin)
         527  +
///     // ...and right after deserialization, model plugins.
         528  +
///     .model_plugin(authorization_plugin)
         529  +
///     .build();
         530  +
/// ```
         531  +
///
         532  +
/// See the [`plugin`] system for details.
         533  +
///
         534  +
/// [`plugin`]: ::aws_smithy_legacy_http_server::plugin
         535  +
#[derive(::std::fmt::Debug)]
         536  +
pub struct SimpleServiceConfig<L, H, M> {
         537  +
    layers: L,
         538  +
    http_plugins: H,
         539  +
    model_plugins: M,
         540  +
}
         541  +
         542  +
impl SimpleServiceConfig<(), (), ()> {
         543  +
    /// Returns a builder to construct the configuration.
         544  +
    pub fn builder() -> SimpleServiceConfigBuilder<
         545  +
        ::tower::layer::util::Identity,
         546  +
        ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         547  +
        ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         548  +
    > {
         549  +
        SimpleServiceConfigBuilder {
         550  +
            layers: ::tower::layer::util::Identity::new(),
         551  +
            http_plugins: ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         552  +
            model_plugins: ::aws_smithy_legacy_http_server::plugin::IdentityPlugin,
         553  +
        }
         554  +
    }
         555  +
}
         556  +
         557  +
/// Builder returned by [`SimpleServiceConfig::builder()`].
         558  +
#[derive(::std::fmt::Debug)]
         559  +
pub struct SimpleServiceConfigBuilder<L, H, M> {
         560  +
    pub(crate) layers: L,
         561  +
    pub(crate) http_plugins: H,
         562  +
    pub(crate) model_plugins: M,
         563  +
}
         564  +
         565  +
impl<L, H, M> SimpleServiceConfigBuilder<L, H, M> {
         566  +
    /// Add a [`::tower::Layer`] to the service.
         567  +
    pub fn layer<NewLayer>(
         568  +
        self,
         569  +
        layer: NewLayer,
         570  +
    ) -> SimpleServiceConfigBuilder<::tower::layer::util::Stack<NewLayer, L>, H, M> {
         571  +
        SimpleServiceConfigBuilder {
         572  +
            layers: ::tower::layer::util::Stack::new(layer, self.layers),
         573  +
            http_plugins: self.http_plugins,
         574  +
            model_plugins: self.model_plugins,
         575  +
        }
         576  +
    }
         577  +
         578  +
    /// Add a HTTP [plugin] to the service.
         579  +
    ///
         580  +
    /// [plugin]: ::aws_smithy_legacy_http_server::plugin
         581  +
    // We eagerly require `NewPlugin: HttpMarker`, despite not really needing it, because compiler
         582  +
    // errors get _substantially_ better if the user makes a mistake.
         583  +
    pub fn http_plugin<NewPlugin: ::aws_smithy_legacy_http_server::plugin::HttpMarker>(
         584  +
        self,
         585  +
        http_plugin: NewPlugin,
         586  +
    ) -> SimpleServiceConfigBuilder<
         587  +
        L,
         588  +
        ::aws_smithy_legacy_http_server::plugin::PluginStack<NewPlugin, H>,
         589  +
        M,
         590  +
    > {
         591  +
        SimpleServiceConfigBuilder {
         592  +
            layers: self.layers,
         593  +
            http_plugins: ::aws_smithy_legacy_http_server::plugin::PluginStack::new(
         594  +
                http_plugin,
         595  +
                self.http_plugins,
         596  +
            ),
         597  +
            model_plugins: self.model_plugins,
         598  +
        }
         599  +
    }
         600  +
         601  +
    /// Add a model [plugin] to the service.
         602  +
    ///
         603  +
    /// [plugin]: ::aws_smithy_legacy_http_server::plugin
         604  +
    // We eagerly require `NewPlugin: ModelMarker`, despite not really needing it, because compiler
         605  +
    // errors get _substantially_ better if the user makes a mistake.
         606  +
    pub fn model_plugin<NewPlugin: ::aws_smithy_legacy_http_server::plugin::ModelMarker>(
         607  +
        self,
         608  +
        model_plugin: NewPlugin,
         609  +
    ) -> SimpleServiceConfigBuilder<
         610  +
        L,
         611  +
        H,
         612  +
        ::aws_smithy_legacy_http_server::plugin::PluginStack<NewPlugin, M>,
         613  +
    > {
         614  +
        SimpleServiceConfigBuilder {
         615  +
            layers: self.layers,
         616  +
            http_plugins: self.http_plugins,
         617  +
            model_plugins: ::aws_smithy_legacy_http_server::plugin::PluginStack::new(
         618  +
                model_plugin,
         619  +
                self.model_plugins,
         620  +
            ),
         621  +
        }
         622  +
    }
         623  +
         624  +
    /// Build the configuration.
         625  +
    pub fn build(self) -> super::SimpleServiceConfig<L, H, M> {
         626  +
        super::SimpleServiceConfig {
         627  +
            layers: self.layers,
         628  +
            http_plugins: self.http_plugins,
         629  +
            model_plugins: self.model_plugins,
         630  +
        }
         631  +
    }
         632  +
}
         633  +
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
         634  +
///
         635  +
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
         636  +
/// of the service and any operations _not_ specified will be placed in the opposing group.
         637  +
///
         638  +
/// # Example
         639  +
///
         640  +
/// ```rust
         641  +
/// scope! {
         642  +
///     /// Includes [`Operation`], excluding all other operations.
         643  +
///     struct ScopeA {
         644  +
///         includes: [Operation]
         645  +
///     }
         646  +
/// }
         647  +
///
         648  +
/// scope! {
         649  +
///     /// Excludes [`Operation`], excluding all other operations.
         650  +
///     struct ScopeB {
         651  +
///         excludes: [Operation]
         652  +
///     }
         653  +
/// }
         654  +
///
         655  +
/// # use simple_http0x::server::plugin::{Plugin, Scoped};
         656  +
/// # use simple_http0x::scope;
         657  +
/// # struct MockPlugin;
         658  +
/// # impl<S, Op, T> Plugin<S, Op, T> for MockPlugin { type Output = u32; fn apply(&self, input: T) -> u32 { 3 } }
         659  +
/// # let scoped_a = Scoped::new::<ScopeA>(MockPlugin);
         660  +
/// # let scoped_b = Scoped::new::<ScopeB>(MockPlugin);
         661  +
/// # let a = Plugin::<(), simple_http0x::operation_shape::Operation, u64>::apply(&scoped_a, 6);
         662  +
/// # let b = Plugin::<(), simple_http0x::operation_shape::Operation, u64>::apply(&scoped_b, 6);
         663  +
/// # assert_eq!(a, 3_u32);
         664  +
/// # assert_eq!(b, 6_u64);
         665  +
/// ```
         666  +
#[macro_export]
         667  +
macro_rules! scope {
         668  +
                    // Completed, render impls
         669  +
                    (@ $ name: ident, $ contains: ident () ($($ temp: ident)*) ($($ not_member: ident)*)) => {
         670  +
                        $(
         671  +
                            impl $ crate::server::plugin::scoped::Membership<$ temp> for $ name {
         672  +
                                type Contains = $ crate::server::plugin::scoped::$ contains;
         673  +
                            }
         674  +
                        )*
         675  +
                        $(
         676  +
                            impl $ crate::server::plugin::scoped::Membership<$ not_member> for $ name {
         677  +
                                type Contains = $ crate::server::plugin::scoped::$ contains;
         678  +
                            }
         679  +
                        )*
         680  +
                    };
         681  +
                    // All `not_member`s exhausted, move `temp` into `not_member`
         682  +
                    (@ $ name: ident, $ contains: ident ($($ member: ident)*) ($($ temp: ident)*) ()) => {
         683  +
                        scope! { @ $ name, $ contains ($($ member)*) () ($($ temp)*) }
         684  +
                    };
         685  +
         686  +
                        // Operation match found, pop from both `member` and `not_member`
         687  +
                        (@ $ name: ident, $ contains: ident (Operation $($ member: ident)*) ($($ temp: ident)*) (Operation $($ not_member: ident)*)) => {
         688  +
                            scope! { @ $ name, $ contains ($($ member)*) ($($ temp)*) ($($ not_member)*) }
         689  +
                        };
         690  +
                        // Operation match not found, pop from `not_member` into `temp` stack
         691  +
                        (@ $ name: ident, $ contains: ident (Operation $($ member: ident)*) ($($ temp: ident)*) ($ other: ident $($ not_member: ident)*)) => {
         692  +
                            scope! { @ $ name, $ contains (Operation $($ member)*) ($ other $($ temp)*) ($($ not_member)*) }
         693  +
                        };
         694  +
         695  +
                    (
         696  +
                        $(#[$ attrs:meta])*
         697  +
                        $ vis:vis struct $ name:ident {
         698  +
                            includes: [$($ include:ident),*]
         699  +
                        }
         700  +
                    ) => {
         701  +
                        use $ crate::operation_shape::*;
         702  +
                        $ crate::server::scope! {
         703  +
                            $(#[$ attrs])*
         704  +
                            $ vis struct $ name {
         705  +
                                includes: [$($ include),*],
         706  +
                                excludes: []
         707  +
                            }
         708  +
                        }
         709  +
                        scope! { @ $ name, False ($($ include)*) () (Operation) }
         710  +
                    };
         711  +
                    (
         712  +
                        $(#[$ attrs:meta])*
         713  +
                        $ vis:vis struct $ name:ident {
         714  +
                            excludes: [$($ exclude:ident),*]
         715  +
                        }
         716  +
                    ) => {
         717  +
                        use $ crate::operation_shape::*;
         718  +
         719  +
                        $ crate::server::scope! {
         720  +
                            $(#[$ attrs])*
         721  +
                            $ vis struct $ name {
         722  +
                                includes: [],
         723  +
                                excludes: [$($ exclude),*]
         724  +
                            }
         725  +
                        }
         726  +
                        scope! { @ $ name, True ($($ exclude)*) () (Operation) }
         727  +
                    };
         728  +
                }

tmp-codegen-diff/codegen-server-test/simple-http0x/rust-server-codegen/src/types.rs

@@ -0,1 +0,5 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub use ::aws_smithy_types::date_time::Format as DateTimeFormat;
           3  +
pub use ::aws_smithy_types::error::display::DisplayErrorContext;
           4  +
pub use ::aws_smithy_types::Blob;
           5  +
pub use ::aws_smithy_types::DateTime;

tmp-codegen-diff/codegen-server-test/simple/rust-server-codegen/Cargo.toml

@@ -1,1 +46,49 @@
   10     10   
codegen-version = "ci"
   11     11   
protocol = "aws.protocols#restJson1"
   12     12   
[dependencies.aws-smithy-http]
   13     13   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http"
   14     14   
[dependencies.aws-smithy-http-server]
   15     15   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http-server"
   16     16   
[dependencies.aws-smithy-json]
   17     17   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-json"
   18     18   
[dependencies.aws-smithy-runtime-api]
   19     19   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-runtime-api"
          20  +
features = ["http-1x"]
   20     21   
[dependencies.aws-smithy-types]
   21     22   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-types"
          23  +
features = ["http-body-1-x"]
   22     24   
[dependencies.futures-util]
   23     25   
version = "0.3"
   24         -
[dependencies.http]
   25         -
version = "0.2.9"
   26         -
[dependencies.hyper]
   27         -
version = "0.14.26"
          26  +
[dependencies.http-1x]
          27  +
version = "1"
          28  +
package = "http"
          29  +
[dependencies.http-body-util]
          30  +
version = "0.1.3"
   28     31   
[dependencies.mime]
   29     32   
version = "0.3"
   30     33   
[dependencies.pin-project-lite]
   31     34   
version = "0.2"
   32     35   
[dependencies.tower]
   33     36   
version = "0.4"
   34     37   
[dependencies.tracing]
   35     38   
version = "0.1"
   36     39   
[dev-dependencies.hyper]
   37         -
version = "0.14.12"
          40  +
version = "1"
   38     41   
[dev-dependencies.tokio]
   39     42   
version = "1.23.1"
   40     43   
[features]
   41     44   
rt-tokio = ["aws-smithy-types/rt-tokio"]
   42     45   
aws-lambda = ["aws-smithy-http-server/aws-lambda"]
   43     46   
request-id = ["aws-smithy-http-server/request-id"]
   44     47   
default = ["rt-tokio", "request-id"]
   45     48   
   46     49   

tmp-codegen-diff/codegen-server-test/simple/rust-server-codegen/src/lib.rs

@@ -19,19 +128,131 @@
   39     39   
)]
   40     40   
//! The [`crate::input`], and [`crate::output`],
   41     41   
//! modules provide the types used in each operation.
   42     42   
//!
   43     43   
//! ### Running on Hyper
   44     44   
//!
   45     45   
//! ```rust,no_run
   46     46   
//! # use std::net::SocketAddr;
   47     47   
//! # async fn dummy() {
   48     48   
//! use simple::{SimpleService, SimpleServiceConfig};
          49  +
//! use simple::serve;
          50  +
//! use ::tokio::net::TcpListener;
   49     51   
//!
   50     52   
//! # let app = SimpleService::builder(
   51     53   
//! #     SimpleServiceConfig::builder()
   52     54   
//! #         .build()
   53     55   
//! # ).build_unchecked();
   54         -
//! let server = app.into_make_service();
   55     56   
//! let bind: SocketAddr = "127.0.0.1:6969".parse()
   56     57   
//!     .expect("unable to parse the server bind address and port");
   57         -
//! ::hyper::Server::bind(&bind).serve(server).await.unwrap();
          58  +
//! let listener = TcpListener::bind(bind).await
          59  +
//!     .expect("failed to bind TCP listener");
          60  +
//! serve(listener, app.into_make_service()).await.unwrap();
   58     61   
//! # }
   59     62   
//! ```
   60     63   
//!
   61     64   
//! ### Running on Lambda
   62     65   
//!
   63     66   
//! ```rust,ignore
   64     67   
//! use simple::server::routing::LambdaHandler;
   65     68   
//! use simple::SimpleService;
   66     69   
//!
   67     70   
//! # async fn dummy() {
   68     71   
//! # let app = SimpleService::builder(
   69     72   
//! #     SimpleServiceConfig::builder()
   70     73   
//! #         .build()
   71     74   
//! # ).build_unchecked();
   72     75   
//! let handler = LambdaHandler::new(app);
   73     76   
//! lambda_http::run(handler).await.unwrap();
   74     77   
//! # }
   75     78   
//! ```
   76     79   
//!
   77     80   
//! # Building the SimpleService
   78     81   
//!
   79     82   
//! To construct [`SimpleService`] we use [`SimpleServiceBuilder`] returned by [`SimpleService::builder`].
   80     83   
//!
   81     84   
//! ## Plugins
   82     85   
//!
   83     86   
//! The [`SimpleService::builder`] method, returning [`SimpleServiceBuilder`],
   84     87   
//! accepts a config object on which plugins can be registered.
   85     88   
//! Plugins allow you to build middleware which is aware of the operation it is being applied to.
   86     89   
//!
   87     90   
//! ```rust,no_run
   88     91   
//! # use simple::server::plugin::IdentityPlugin as LoggingPlugin;
   89     92   
//! # use simple::server::plugin::IdentityPlugin as MetricsPlugin;
   90         -
//! # use ::hyper::Body;
          93  +
//! # use ::hyper::body::Incoming;
   91     94   
//! use simple::server::plugin::HttpPlugins;
   92     95   
//! use simple::{SimpleService, SimpleServiceConfig, SimpleServiceBuilder};
   93     96   
//!
   94     97   
//! let http_plugins = HttpPlugins::new()
   95     98   
//!         .push(LoggingPlugin)
   96     99   
//!         .push(MetricsPlugin);
   97    100   
//! let config = SimpleServiceConfig::builder().build();
   98         -
//! let builder: SimpleServiceBuilder<Body, _, _, _> = SimpleService::builder(config);
         101  +
//! let builder: SimpleServiceBuilder<::hyper::body::Incoming, _, _, _> = SimpleService::builder(config);
   99    102   
//! ```
  100    103   
//!
  101    104   
//! Check out [`crate::server::plugin`] to learn more about plugins.
  102    105   
//!
  103    106   
//! ## Handlers
  104    107   
//!
  105    108   
//! [`SimpleServiceBuilder`] provides a setter method for each operation in your Smithy model. The setter methods expect an async function as input, matching the signature for the corresponding operation in your Smithy model.
  106    109   
//! We call these async functions **handlers**. This is where your application business logic lives.
  107    110   
//!
  108    111   
//! Every handler must take an `Input`, and optional [`extractor arguments`](crate::server::request), while returning:
@@ -135,138 +228,235 @@
  155    158   
//! [`SimpleServiceBuilder::build`] requires you to provide a handler for every single operation in your Smithy model. It will return an error if that is not the case.
  156    159   
//!
  157    160   
//! [`SimpleServiceBuilder::build_unchecked`], instead, does not require exhaustiveness. The server will automatically return 500 Internal Server Error to all requests for operations that do not have a registered handler.
  158    161   
//! [`SimpleServiceBuilder::build_unchecked`] is particularly useful if you are deploying your Smithy service as a collection of Lambda functions, where each Lambda is only responsible for a subset of the operations in the Smithy service (or even a single one!).
  159    162   
//!
  160    163   
//! # Example
  161    164   
//!
  162    165   
//! ```rust,no_run
  163    166   
//! # use std::net::SocketAddr;
  164    167   
//! use simple::{SimpleService, SimpleServiceConfig};
         168  +
//! use simple::serve;
         169  +
//! use ::tokio::net::TcpListener;
  165    170   
//!
  166    171   
//! #[::tokio::main]
  167    172   
//! pub async fn main() {
  168    173   
//!    let config = SimpleServiceConfig::builder().build();
  169    174   
//!    let app = SimpleService::builder(config)
  170    175   
//!        .operation(operation)
  171    176   
//!        .build()
  172    177   
//!        .expect("failed to build an instance of SimpleService");
  173    178   
//!
  174    179   
//!    let bind: SocketAddr = "127.0.0.1:6969".parse()
  175    180   
//!        .expect("unable to parse the server bind address and port");
  176         -
//!    let server = ::hyper::Server::bind(&bind).serve(app.into_make_service());
         181  +
//!    let listener = TcpListener::bind(bind).await
         182  +
//!        .expect("failed to bind TCP listener");
  177    183   
//!    # let server = async { Ok::<_, ()>(()) };
  178    184   
//!
  179    185   
//!    // Run your service!
  180         -
//!    if let Err(err) = server.await {
         186  +
//!    if let Err(err) = serve(listener, app.into_make_service()).await {
  181    187   
//!        eprintln!("server error: {:?}", err);
  182    188   
//!    }
  183    189   
//! }
  184    190   
//!
  185    191   
//! use simple::{input, output};
  186    192   
//!
  187    193   
//! async fn operation(input: input::OperationInput) -> output::OperationOutput {
  188    194   
//!     todo!()
  189    195   
//! }
  190    196   
//!
  191    197   
//! ```
  192    198   
//!
  193         -
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
         199  +
//! [`serve`]: crate::serve
         200  +
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  194    201   
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
  195    202   
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
  196    203   
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
  197         -
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  198    204   
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         205  +
pub use crate::server::serve::serve;
  199    206   
pub use crate::service::{
  200    207   
    MissingOperationsError, SimpleService, SimpleServiceBuilder, SimpleServiceConfig,
  201    208   
    SimpleServiceConfigBuilder,
  202    209   
};
  203    210   
  204    211   
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
  205    212   
pub mod server {
  206    213   
    // Re-export all types from the `aws-smithy-http-server` crate.
  207    214   
    pub use ::aws_smithy_http_server::*;
  208    215   
}