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