1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | ::pin_project_lite::pin_project! {
|
3 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4 + | /// [`HttpQueryParamsOnlyOperationInput`](crate::input::HttpQueryParamsOnlyOperationInput) using modelled bindings.
|
5 + | pub struct HttpQueryParamsOnlyOperationInputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::HttpQueryParamsOnlyOperationInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7 + | }
|
8 + | }
|
9 + |
|
10 + | impl std::future::Future for HttpQueryParamsOnlyOperationInputFuture {
|
11 + | type Output = Result<
|
12 + | crate::input::HttpQueryParamsOnlyOperationInput,
|
13 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
14 + | >;
|
15 + |
|
16 + | fn poll(
|
17 + | self: std::pin::Pin<&mut Self>,
|
18 + | cx: &mut std::task::Context<'_>,
|
19 + | ) -> std::task::Poll<Self::Output> {
|
20 + | let this = self.project();
|
21 + | this.inner.as_mut().poll(cx)
|
22 + | }
|
23 + | }
|
24 + |
|
25 + | impl<B>
|
26 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
27 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
28 + | B,
|
29 + | > for crate::input::HttpQueryParamsOnlyOperationInput
|
30 + | where
|
31 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
32 + | B: 'static,
|
33 + |
|
34 + | B::Data: Send,
|
35 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
36 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
37 + | {
|
38 + | type Rejection =
|
39 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
40 + | type Future = HttpQueryParamsOnlyOperationInputFuture;
|
41 + |
|
42 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
43 + | let fut = async move {
|
44 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
45 + | request.headers(),
|
46 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
47 + | ) {
|
48 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
49 + | }
|
50 + | crate::protocol_serde::shape_http_query_params_only_operation::de_http_query_params_only_operation_http_request(request)
|
51 + | .await
|
52 + | };
|
53 + | use ::futures_util::future::TryFutureExt;
|
54 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
55 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
56 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
57 + | });
|
58 + | HttpQueryParamsOnlyOperationInputFuture {
|
59 + | inner: Box::pin(fut),
|
60 + | }
|
61 + | }
|
62 + | }
|
63 + | impl
|
64 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
65 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
66 + | > for crate::output::HttpQueryParamsOnlyOperationOutput
|
67 + | {
|
68 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
69 + | match crate::protocol_serde::shape_http_query_params_only_operation::ser_http_query_params_only_operation_http_response(self) {
|
70 + | Ok(response) => response,
|
71 + | Err(e) => {
|
72 + | ::tracing::error!(error = %e, "failed to serialize response");
|
73 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
74 + | }
|
75 + | }
|
76 + | }
|
77 + | }
|
78 + | impl
|
79 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
80 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
81 + | > for crate::error::HttpQueryParamsOnlyOperationError
|
82 + | {
|
83 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
84 + | match crate::protocol_serde::shape_http_query_params_only_operation::ser_http_query_params_only_operation_http_error(&self) {
|
85 + | Ok(mut response) => {
|
86 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
87 + | response
|
88 + | },
|
89 + | Err(e) => {
|
90 + | ::tracing::error!(error = %e, "failed to serialize response");
|
91 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
92 + | }
|
93 + | }
|
94 + | }
|
95 + | }
|
96 + |
|
97 + | #[allow(unreachable_code, unused_variables)]
|
98 + | #[cfg(test)]
|
99 + | mod http_query_params_only_operation_test {
|
100 + |
|
101 + | /// Upper case error modeled lower case.
|
102 + | /// Test ID: ServiceLevelErrorServer
|
103 + | #[::tokio::test]
|
104 + | #[::tracing_test::traced_test]
|
105 + | async fn service_level_error_server_response() {
|
106 + | let output = crate::error::ExtraError {};
|
107 + | let output = crate::error::HttpQueryParamsOnlyOperationError::ExtraError(output);
|
108 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
109 + | let http_response = output.into_response();
|
110 + | ::pretty_assertions::assert_eq!(
|
111 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
112 + | http_response.status()
|
113 + | );
|
114 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
115 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
116 + | http_response.headers(),
|
117 + | expected_headers,
|
118 + | ));
|
119 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
120 + | .await
|
121 + | .expect("unable to extract body to bytes");
|
122 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
123 + | &body,
|
124 + | "{}",
|
125 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
126 + | ));
|
127 + | }
|
128 + | }
|
129 + |
|
130 + | ::pin_project_lite::pin_project! {
|
131 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
132 + | /// [`QueryPrecedenceInput`](crate::input::QueryPrecedenceInput) using modelled bindings.
|
133 + | pub struct QueryPrecedenceInputFuture {
|
134 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::QueryPrecedenceInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
135 + | }
|
136 + | }
|
137 + |
|
138 + | impl std::future::Future for QueryPrecedenceInputFuture {
|
139 + | type Output = Result<
|
140 + | crate::input::QueryPrecedenceInput,
|
141 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
142 + | >;
|
143 + |
|
144 + | fn poll(
|
145 + | self: std::pin::Pin<&mut Self>,
|
146 + | cx: &mut std::task::Context<'_>,
|
147 + | ) -> std::task::Poll<Self::Output> {
|
148 + | let this = self.project();
|
149 + | this.inner.as_mut().poll(cx)
|
150 + | }
|
151 + | }
|
152 + |
|
153 + | impl<B>
|
154 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
155 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
156 + | B,
|
157 + | > for crate::input::QueryPrecedenceInput
|
158 + | where
|
159 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
160 + | B: 'static,
|
161 + |
|
162 + | B::Data: Send,
|
163 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
164 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
165 + | {
|
166 + | type Rejection =
|
167 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
168 + | type Future = QueryPrecedenceInputFuture;
|
169 + |
|
170 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
171 + | let fut = async move {
|
172 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
173 + | request.headers(),
|
174 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
175 + | ) {
|
176 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
177 + | }
|
178 + | crate::protocol_serde::shape_query_precedence::de_query_precedence_http_request(request)
|
179 + | .await
|
180 + | };
|
181 + | use ::futures_util::future::TryFutureExt;
|
182 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
183 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
184 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
185 + | });
|
186 + | QueryPrecedenceInputFuture {
|
187 + | inner: Box::pin(fut),
|
188 + | }
|
189 + | }
|
190 + | }
|
191 + | impl
|
192 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
193 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
194 + | > for crate::output::QueryPrecedenceOutput
|
195 + | {
|
196 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
197 + | match crate::protocol_serde::shape_query_precedence::ser_query_precedence_http_response(
|
198 + | self,
|
199 + | ) {
|
200 + | Ok(response) => response,
|
201 + | Err(e) => {
|
202 + | ::tracing::error!(error = %e, "failed to serialize response");
|
203 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
204 + | }
|
205 + | }
|
206 + | }
|
207 + | }
|
208 + | impl
|
209 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
210 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
211 + | > for crate::error::QueryPrecedenceError
|
212 + | {
|
213 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
214 + | match crate::protocol_serde::shape_query_precedence::ser_query_precedence_http_error(&self)
|
215 + | {
|
216 + | Ok(mut response) => {
|
217 + | response.extensions_mut().insert(
|
218 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
219 + | self.name(),
|
220 + | ),
|
221 + | );
|
222 + | response
|
223 + | }
|
224 + | Err(e) => {
|
225 + | ::tracing::error!(error = %e, "failed to serialize response");
|
226 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
227 + | }
|
228 + | }
|
229 + | }
|
230 + | }
|
231 + |
|
232 + | #[allow(unreachable_code, unused_variables)]
|
233 + | #[cfg(test)]
|
234 + | mod query_precedence_test {
|
235 + |
|
236 + | /// Servers put all query params in map
|
237 + | /// Test ID: RestJsonServersPutAllQueryParamsInMap
|
238 + | #[::tokio::test]
|
239 + | #[::tracing_test::traced_test]
|
240 + | async fn rest_json_servers_put_all_query_params_in_map_request() {
|
241 + | #[allow(unused_mut)]
|
242 + | let mut http_request = ::http::Request::builder()
|
243 + | .uri("/Precedence")
|
244 + | .method("POST")
|
245 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
246 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
247 + | "".as_bytes(),
|
248 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
249 + | )),
|
250 + | ))
|
251 + | .unwrap();
|
252 + | *http_request.uri_mut() = "/Precedence?bar=named&qux=fromMap".parse().unwrap();
|
253 + | #[allow(unused_mut)]
|
254 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
255 + | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
256 + | let service =
|
257 + | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
258 + | .query_precedence(move |input: crate::input::QueryPrecedenceInput| {
|
259 + | let sender = sender.clone();
|
260 + | async move {
|
261 + | let result = {
|
262 + | let expected = crate::input::QueryPrecedenceInput {
|
263 + | foo: ::std::option::Option::Some("named".to_owned()),
|
264 + | baz: ::std::option::Option::Some({
|
265 + | let mut ret = ::std::collections::HashMap::new();
|
266 + | ret.insert("bar".to_owned(), "named".to_owned());
|
267 + | ret.insert("qux".to_owned(), "fromMap".to_owned());
|
268 + | ret
|
269 + | }),
|
270 + | };
|
271 + | ::pretty_assertions::assert_eq!(input, expected);
|
272 + | let output = crate::output::QueryPrecedenceOutput {};
|
273 + | Ok(output)
|
274 + | };
|
275 + | sender.send(()).await.expect("receiver dropped early");
|
276 + | result
|
277 + | }
|
278 + | })
|
279 + | .build_unchecked();
|
280 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
281 + | .await
|
282 + | .expect("unable to make an HTTP request");
|
283 + | assert!(
|
284 + | receiver.recv().await.is_some(),
|
285 + | "we expected operation handler to be invoked but it was not entered"
|
286 + | );
|
287 + | }
|
288 + |
|
289 + | /// Upper case error modeled lower case.
|
290 + | /// Test ID: ServiceLevelErrorServer
|
291 + | #[::tokio::test]
|
292 + | #[::tracing_test::traced_test]
|
293 + | async fn service_level_error_server_response() {
|
294 + | let output = crate::error::ExtraError {};
|
295 + | let output = crate::error::QueryPrecedenceError::ExtraError(output);
|
296 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
297 + | let http_response = output.into_response();
|
298 + | ::pretty_assertions::assert_eq!(
|
299 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
300 + | http_response.status()
|
301 + | );
|
302 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
303 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
304 + | http_response.headers(),
|
305 + | expected_headers,
|
306 + | ));
|
307 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
308 + | .await
|
309 + | .expect("unable to extract body to bytes");
|
310 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
311 + | &body,
|
312 + | "{}",
|
313 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
314 + | ));
|
315 + | }
|
316 + | }
|
317 + |
|
318 + | ::pin_project_lite::pin_project! {
|
319 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
320 + | /// [`EmptyStructWithContentOnWireOpInput`](crate::input::EmptyStructWithContentOnWireOpInput) using modelled bindings.
|
321 + | pub struct EmptyStructWithContentOnWireOpInputFuture {
|
322 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyStructWithContentOnWireOpInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
323 + | }
|
324 + | }
|
325 + |
|
326 + | impl std::future::Future for EmptyStructWithContentOnWireOpInputFuture {
|
327 + | type Output = Result<
|
328 + | crate::input::EmptyStructWithContentOnWireOpInput,
|
329 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
330 + | >;
|
331 + |
|
332 + | fn poll(
|
333 + | self: std::pin::Pin<&mut Self>,
|
334 + | cx: &mut std::task::Context<'_>,
|
335 + | ) -> std::task::Poll<Self::Output> {
|
336 + | let this = self.project();
|
337 + | this.inner.as_mut().poll(cx)
|
338 + | }
|
339 + | }
|
340 + |
|
341 + | impl<B>
|
342 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
343 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
344 + | B,
|
345 + | > for crate::input::EmptyStructWithContentOnWireOpInput
|
346 + | where
|
347 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
348 + | B: 'static,
|
349 + |
|
350 + | B::Data: Send,
|
351 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
352 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
353 + | {
|
354 + | type Rejection =
|
355 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
356 + | type Future = EmptyStructWithContentOnWireOpInputFuture;
|
357 + |
|
358 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
359 + | let fut = async move {
|
360 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
361 + | request.headers(),
|
362 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
363 + | ) {
|
364 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
365 + | }
|
366 + | crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::de_empty_struct_with_content_on_wire_op_http_request(request)
|
367 + | .await
|
368 + | };
|
369 + | use ::futures_util::future::TryFutureExt;
|
370 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
371 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
372 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
373 + | });
|
374 + | EmptyStructWithContentOnWireOpInputFuture {
|
375 + | inner: Box::pin(fut),
|
376 + | }
|
377 + | }
|
378 + | }
|
379 + | impl
|
380 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
381 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
382 + | > for crate::output::EmptyStructWithContentOnWireOpOutput
|
383 + | {
|
384 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
385 + | match crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::ser_empty_struct_with_content_on_wire_op_http_response(self) {
|
386 + | Ok(response) => response,
|
387 + | Err(e) => {
|
388 + | ::tracing::error!(error = %e, "failed to serialize response");
|
389 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
390 + | }
|
391 + | }
|
392 + | }
|
393 + | }
|
394 + | impl
|
395 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
396 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
397 + | > for crate::error::EmptyStructWithContentOnWireOpError
|
398 + | {
|
399 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
400 + | match crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::ser_empty_struct_with_content_on_wire_op_http_error(&self) {
|
401 + | Ok(mut response) => {
|
402 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
403 + | response
|
404 + | },
|
405 + | Err(e) => {
|
406 + | ::tracing::error!(error = %e, "failed to serialize response");
|
407 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
408 + | }
|
409 + | }
|
410 + | }
|
411 + | }
|
412 + |
|
413 + | #[allow(unreachable_code, unused_variables)]
|
414 + | #[cfg(test)]
|
415 + | mod empty_struct_with_content_on_wire_op_test {
|
416 + |
|
417 + | /// Upper case error modeled lower case.
|
418 + | /// Test ID: ServiceLevelErrorServer
|
419 + | #[::tokio::test]
|
420 + | #[::tracing_test::traced_test]
|
421 + | async fn service_level_error_server_response() {
|
422 + | let output = crate::error::ExtraError {};
|
423 + | let output = crate::error::EmptyStructWithContentOnWireOpError::ExtraError(output);
|
424 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
425 + | let http_response = output.into_response();
|
426 + | ::pretty_assertions::assert_eq!(
|
427 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
428 + | http_response.status()
|
429 + | );
|
430 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
431 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
432 + | http_response.headers(),
|
433 + | expected_headers,
|
434 + | ));
|
435 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
436 + | .await
|
437 + | .expect("unable to extract body to bytes");
|
438 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
439 + | &body,
|
440 + | "{}",
|
441 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
442 + | ));
|
443 + | }
|
444 + | }
|
445 + |
|
446 + | ::pin_project_lite::pin_project! {
|
447 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
448 + | /// [`CaseInsensitiveErrorOperationInput`](crate::input::CaseInsensitiveErrorOperationInput) using modelled bindings.
|
449 + | pub struct CaseInsensitiveErrorOperationInputFuture {
|
450 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::CaseInsensitiveErrorOperationInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
451 + | }
|
452 + | }
|
453 + |
|
454 + | impl std::future::Future for CaseInsensitiveErrorOperationInputFuture {
|
455 + | type Output = Result<
|
456 + | crate::input::CaseInsensitiveErrorOperationInput,
|
457 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
458 + | >;
|
459 + |
|
460 + | fn poll(
|
461 + | self: std::pin::Pin<&mut Self>,
|
462 + | cx: &mut std::task::Context<'_>,
|
463 + | ) -> std::task::Poll<Self::Output> {
|
464 + | let this = self.project();
|
465 + | this.inner.as_mut().poll(cx)
|
466 + | }
|
467 + | }
|
468 + |
|
469 + | impl<B>
|
470 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
471 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
472 + | B,
|
473 + | > for crate::input::CaseInsensitiveErrorOperationInput
|
474 + | where
|
475 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
476 + | B: 'static,
|
477 + |
|
478 + | B::Data: Send,
|
479 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
480 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
481 + | {
|
482 + | type Rejection =
|
483 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
484 + | type Future = CaseInsensitiveErrorOperationInputFuture;
|
485 + |
|
486 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
487 + | let fut = async move {
|
488 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
489 + | request.headers(),
|
490 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
491 + | ) {
|
492 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
493 + | }
|
494 + | crate::protocol_serde::shape_case_insensitive_error_operation::de_case_insensitive_error_operation_http_request(request)
|
495 + | .await
|
496 + | };
|
497 + | use ::futures_util::future::TryFutureExt;
|
498 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
499 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
500 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
501 + | });
|
502 + | CaseInsensitiveErrorOperationInputFuture {
|
503 + | inner: Box::pin(fut),
|
504 + | }
|
505 + | }
|
506 + | }
|
507 + | impl
|
508 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
509 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
510 + | > for crate::output::CaseInsensitiveErrorOperationOutput
|
511 + | {
|
512 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
513 + | match crate::protocol_serde::shape_case_insensitive_error_operation::ser_case_insensitive_error_operation_http_response(self) {
|
514 + | Ok(response) => response,
|
515 + | Err(e) => {
|
516 + | ::tracing::error!(error = %e, "failed to serialize response");
|
517 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
518 + | }
|
519 + | }
|
520 + | }
|
521 + | }
|
522 + | impl
|
523 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
524 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
525 + | > for crate::error::CaseInsensitiveErrorOperationError
|
526 + | {
|
527 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
528 + | match crate::protocol_serde::shape_case_insensitive_error_operation::ser_case_insensitive_error_operation_http_error(&self) {
|
529 + | Ok(mut response) => {
|
530 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
531 + | response
|
532 + | },
|
533 + | Err(e) => {
|
534 + | ::tracing::error!(error = %e, "failed to serialize response");
|
535 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
536 + | }
|
537 + | }
|
538 + | }
|
539 + | }
|
540 + |
|
541 + | #[allow(unreachable_code, unused_variables)]
|
542 + | #[cfg(test)]
|
543 + | mod case_insensitive_error_operation_test {
|
544 + |
|
545 + | /// Upper case error modeled lower case.
|
546 + | /// Test ID: ServiceLevelErrorServer
|
547 + | #[::tokio::test]
|
548 + | #[::tracing_test::traced_test]
|
549 + | async fn service_level_error_server_response() {
|
550 + | let output = crate::error::ExtraError {};
|
551 + | let output = crate::error::CaseInsensitiveErrorOperationError::ExtraError(output);
|
552 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
553 + | let http_response = output.into_response();
|
554 + | ::pretty_assertions::assert_eq!(
|
555 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
556 + | http_response.status()
|
557 + | );
|
558 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
559 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
560 + | http_response.headers(),
|
561 + | expected_headers,
|
562 + | ));
|
563 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
564 + | .await
|
565 + | .expect("unable to extract body to bytes");
|
566 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
567 + | &body,
|
568 + | "{}",
|
569 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
570 + | ));
|
571 + | }
|
572 + | }
|
573 + |
|
574 + | ::pin_project_lite::pin_project! {
|
575 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
576 + | /// [`NullInNonSparseInput`](crate::input::NullInNonSparseInput) using modelled bindings.
|
577 + | pub struct NullInNonSparseInputFuture {
|
578 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NullInNonSparseInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
579 + | }
|
580 + | }
|
581 + |
|
582 + | impl std::future::Future for NullInNonSparseInputFuture {
|
583 + | type Output = Result<
|
584 + | crate::input::NullInNonSparseInput,
|
585 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
586 + | >;
|
587 + |
|
588 + | fn poll(
|
589 + | self: std::pin::Pin<&mut Self>,
|
590 + | cx: &mut std::task::Context<'_>,
|
591 + | ) -> std::task::Poll<Self::Output> {
|
592 + | let this = self.project();
|
593 + | this.inner.as_mut().poll(cx)
|
594 + | }
|
595 + | }
|
596 + |
|
597 + | impl<B>
|
598 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
599 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
600 + | B,
|
601 + | > for crate::input::NullInNonSparseInput
|
602 + | where
|
603 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
604 + | B: 'static,
|
605 + |
|
606 + | B::Data: Send,
|
607 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
608 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
609 + | {
|
610 + | type Rejection =
|
611 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
612 + | type Future = NullInNonSparseInputFuture;
|
613 + |
|
614 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
615 + | let fut = async move {
|
616 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
617 + | request.headers(),
|
618 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
619 + | ) {
|
620 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
621 + | }
|
622 + | crate::protocol_serde::shape_null_in_non_sparse::de_null_in_non_sparse_http_request(
|
623 + | request,
|
624 + | )
|
625 + | .await
|
626 + | };
|
627 + | use ::futures_util::future::TryFutureExt;
|
628 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
629 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
630 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
631 + | });
|
632 + | NullInNonSparseInputFuture {
|
633 + | inner: Box::pin(fut),
|
634 + | }
|
635 + | }
|
636 + | }
|
637 + | impl
|
638 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
639 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
640 + | > for crate::output::NullInNonSparseOutput
|
641 + | {
|
642 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
643 + | match crate::protocol_serde::shape_null_in_non_sparse::ser_null_in_non_sparse_http_response(
|
644 + | self,
|
645 + | ) {
|
646 + | Ok(response) => response,
|
647 + | Err(e) => {
|
648 + | ::tracing::error!(error = %e, "failed to serialize response");
|
649 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
650 + | }
|
651 + | }
|
652 + | }
|
653 + | }
|
654 + | impl
|
655 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
656 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
657 + | > for crate::error::NullInNonSparseError
|
658 + | {
|
659 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
660 + | match crate::protocol_serde::shape_null_in_non_sparse::ser_null_in_non_sparse_http_error(
|
661 + | &self,
|
662 + | ) {
|
663 + | Ok(mut response) => {
|
664 + | response.extensions_mut().insert(
|
665 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
666 + | self.name(),
|
667 + | ),
|
668 + | );
|
669 + | response
|
670 + | }
|
671 + | Err(e) => {
|
672 + | ::tracing::error!(error = %e, "failed to serialize response");
|
673 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
674 + | }
|
675 + | }
|
676 + | }
|
677 + | }
|
678 + |
|
679 + | #[allow(unreachable_code, unused_variables)]
|
680 + | #[cfg(test)]
|
681 + | mod null_in_non_sparse_test {
|
682 + |
|
683 + | /// Upper case error modeled lower case.
|
684 + | /// Test ID: ServiceLevelErrorServer
|
685 + | #[::tokio::test]
|
686 + | #[::tracing_test::traced_test]
|
687 + | async fn service_level_error_server_response() {
|
688 + | let output = crate::error::ExtraError {};
|
689 + | let output = crate::error::NullInNonSparseError::ExtraError(output);
|
690 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
691 + | let http_response = output.into_response();
|
692 + | ::pretty_assertions::assert_eq!(
|
693 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
694 + | http_response.status()
|
695 + | );
|
696 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
697 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
698 + | http_response.headers(),
|
699 + | expected_headers,
|
700 + | ));
|
701 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
702 + | .await
|
703 + | .expect("unable to extract body to bytes");
|
704 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
705 + | &body,
|
706 + | "{}",
|
707 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
708 + | ));
|
709 + | }
|
710 + | }
|
711 + |
|
712 + | ::pin_project_lite::pin_project! {
|
713 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
714 + | /// [`EscapedStringValuesInput`](crate::input::EscapedStringValuesInput) using modelled bindings.
|
715 + | pub struct EscapedStringValuesInputFuture {
|
716 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EscapedStringValuesInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
717 + | }
|
718 + | }
|
719 + |
|
720 + | impl std::future::Future for EscapedStringValuesInputFuture {
|
721 + | type Output = Result<
|
722 + | crate::input::EscapedStringValuesInput,
|
723 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
724 + | >;
|
725 + |
|
726 + | fn poll(
|
727 + | self: std::pin::Pin<&mut Self>,
|
728 + | cx: &mut std::task::Context<'_>,
|
729 + | ) -> std::task::Poll<Self::Output> {
|
730 + | let this = self.project();
|
731 + | this.inner.as_mut().poll(cx)
|
732 + | }
|
733 + | }
|
734 + |
|
735 + | impl<B>
|
736 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
737 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
738 + | B,
|
739 + | > for crate::input::EscapedStringValuesInput
|
740 + | where
|
741 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
742 + | B: 'static,
|
743 + |
|
744 + | B::Data: Send,
|
745 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
746 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
747 + | {
|
748 + | type Rejection =
|
749 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
750 + | type Future = EscapedStringValuesInputFuture;
|
751 + |
|
752 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
753 + | let fut = async move {
|
754 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
755 + | request.headers(),
|
756 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
757 + | ) {
|
758 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
759 + | }
|
760 + | crate::protocol_serde::shape_escaped_string_values::de_escaped_string_values_http_request(request)
|
761 + | .await
|
762 + | };
|
763 + | use ::futures_util::future::TryFutureExt;
|
764 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
765 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
766 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
767 + | });
|
768 + | EscapedStringValuesInputFuture {
|
769 + | inner: Box::pin(fut),
|
770 + | }
|
771 + | }
|
772 + | }
|
773 + | impl
|
774 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
775 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
776 + | > for crate::output::EscapedStringValuesOutput
|
777 + | {
|
778 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
779 + | match crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_http_response(self) {
|
780 + | Ok(response) => response,
|
781 + | Err(e) => {
|
782 + | ::tracing::error!(error = %e, "failed to serialize response");
|
783 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
784 + | }
|
785 + | }
|
786 + | }
|
787 + | }
|
788 + | impl
|
789 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
790 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
791 + | > for crate::error::EscapedStringValuesError
|
792 + | {
|
793 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
794 + | match crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_http_error(&self) {
|
795 + | Ok(mut response) => {
|
796 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
797 + | response
|
798 + | },
|
799 + | Err(e) => {
|
800 + | ::tracing::error!(error = %e, "failed to serialize response");
|
801 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
802 + | }
|
803 + | }
|
804 + | }
|
805 + | }
|
806 + |
|
807 + | #[allow(unreachable_code, unused_variables)]
|
808 + | #[cfg(test)]
|
809 + | mod escaped_string_values_test {
|
810 + |
|
811 + | /// Test ID: EscapedStringValuesRequest
|
812 + | #[::tokio::test]
|
813 + | #[::tracing_test::traced_test]
|
814 + | async fn escaped_string_values_request_request() {
|
815 + | #[allow(unused_mut)]
|
816 + | let mut http_request = ::http::Request::builder()
|
817 + | .uri("/escaped-string-values")
|
818 + | .method("POST")
|
819 + | .header("Content-Type", "application/json")
|
820 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
821 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
822 + | "{\"enum\":\"has\\\"quotes\",\"also\\\"has\\\"quotes\":\"test\"}".as_bytes(),
|
823 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
824 + | )),
|
825 + | ))
|
826 + | .unwrap();
|
827 + | #[allow(unused_mut)]
|
828 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
829 + | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
830 + | let service =
|
831 + | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
832 + | .escaped_string_values(move |input: crate::input::EscapedStringValuesInput| {
|
833 + | let sender = sender.clone();
|
834 + | async move {
|
835 + | let result = {
|
836 + | let expected = crate::input::EscapedStringValuesInput {
|
837 + | r#enum: ::std::option::Option::Some(
|
838 + | "has\"quotes"
|
839 + | .parse::<crate::model::EnumWithEscapedChars>()
|
840 + | .expect("static value validated to member"),
|
841 + | ),
|
842 + | some_string: ::std::option::Option::Some("test".to_owned()),
|
843 + | };
|
844 + | ::pretty_assertions::assert_eq!(input, expected);
|
845 + | let output = crate::output::EscapedStringValuesOutput {
|
846 + | r#enum: ::std::option::Option::None,
|
847 + | some_string: ::std::option::Option::None,
|
848 + | };
|
849 + | Ok(output)
|
850 + | };
|
851 + | sender.send(()).await.expect("receiver dropped early");
|
852 + | result
|
853 + | }
|
854 + | })
|
855 + | .build_unchecked();
|
856 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
857 + | .await
|
858 + | .expect("unable to make an HTTP request");
|
859 + | assert!(
|
860 + | receiver.recv().await.is_some(),
|
861 + | "we expected operation handler to be invoked but it was not entered"
|
862 + | );
|
863 + | }
|
864 + | /// Test ID: EscapedStringValuesResponse
|
865 + | #[::tokio::test]
|
866 + | #[::tracing_test::traced_test]
|
867 + | async fn escaped_string_values_response_response() {
|
868 + | let output = crate::output::EscapedStringValuesOutput {
|
869 + | r#enum: ::std::option::Option::Some(
|
870 + | "has\"quotes"
|
871 + | .parse::<crate::model::EnumWithEscapedChars>()
|
872 + | .expect("static value validated to member"),
|
873 + | ),
|
874 + | some_string: ::std::option::Option::Some("test".to_owned()),
|
875 + | };
|
876 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
877 + | let http_response = output.into_response();
|
878 + | ::pretty_assertions::assert_eq!(
|
879 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
880 + | http_response.status()
|
881 + | );
|
882 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
883 + | .await
|
884 + | .expect("unable to extract body to bytes");
|
885 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
886 + | &body,
|
887 + | "{\"enum\":\"has\\\"quotes\",\"also\\\"has\\\"quotes\":\"test\"}",
|
888 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
889 + | ));
|
890 + | }
|
891 + |
|
892 + | /// Upper case error modeled lower case.
|
893 + | /// Test ID: ServiceLevelErrorServer
|
894 + | #[::tokio::test]
|
895 + | #[::tracing_test::traced_test]
|
896 + | async fn service_level_error_server_response() {
|
897 + | let output = crate::error::ExtraError {};
|
898 + | let output = crate::error::EscapedStringValuesError::ExtraError(output);
|
899 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
900 + | let http_response = output.into_response();
|
901 + | ::pretty_assertions::assert_eq!(
|
902 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
903 + | http_response.status()
|
904 + | );
|
905 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
906 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
907 + | http_response.headers(),
|
908 + | expected_headers,
|
909 + | ));
|
910 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
911 + | .await
|
912 + | .expect("unable to extract body to bytes");
|
913 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
914 + | &body,
|
915 + | "{}",
|
916 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
917 + | ));
|
918 + | }
|
919 + | }
|
920 + |
|
921 + | ::pin_project_lite::pin_project! {
|
922 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
923 + | /// [`PrimitiveIntOpInput`](crate::input::PrimitiveIntOpInput) using modelled bindings.
|
924 + | pub struct PrimitiveIntOpInputFuture {
|
925 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PrimitiveIntOpInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
926 + | }
|
927 + | }
|
928 + |
|
929 + | impl std::future::Future for PrimitiveIntOpInputFuture {
|
930 + | type Output = Result<
|
931 + | crate::input::PrimitiveIntOpInput,
|
932 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
933 + | >;
|
934 + |
|
935 + | fn poll(
|
936 + | self: std::pin::Pin<&mut Self>,
|
937 + | cx: &mut std::task::Context<'_>,
|
938 + | ) -> std::task::Poll<Self::Output> {
|
939 + | let this = self.project();
|
940 + | this.inner.as_mut().poll(cx)
|
941 + | }
|
942 + | }
|
943 + |
|
944 + | impl<B>
|
945 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
946 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
947 + | B,
|
948 + | > for crate::input::PrimitiveIntOpInput
|
949 + | where
|
950 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
951 + | B: 'static,
|
952 + |
|
953 + | B::Data: Send,
|
954 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
955 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
956 + | {
|
957 + | type Rejection =
|
958 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
959 + | type Future = PrimitiveIntOpInputFuture;
|
960 + |
|
961 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
962 + | let fut = async move {
|
963 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
964 + | request.headers(),
|
965 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
966 + | ) {
|
967 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
968 + | }
|
969 + | crate::protocol_serde::shape_primitive_int_op::de_primitive_int_op_http_request(request)
|
970 + | .await
|
971 + | };
|
972 + | use ::futures_util::future::TryFutureExt;
|
973 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
974 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
975 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
976 + | });
|
977 + | PrimitiveIntOpInputFuture {
|
978 + | inner: Box::pin(fut),
|
979 + | }
|
980 + | }
|
981 + | }
|
982 + | impl
|
983 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
984 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
985 + | > for crate::output::PrimitiveIntOpOutput
|
986 + | {
|
987 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
988 + | match crate::protocol_serde::shape_primitive_int_op::ser_primitive_int_op_http_response(
|
989 + | self,
|
990 + | ) {
|
991 + | Ok(response) => response,
|
992 + | Err(e) => {
|
993 + | ::tracing::error!(error = %e, "failed to serialize response");
|
994 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
995 + | }
|
996 + | }
|
997 + | }
|
998 + | }
|
999 + | impl
|
1000 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1001 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1002 + | > for crate::error::PrimitiveIntOpError
|
1003 + | {
|
1004 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1005 + | match crate::protocol_serde::shape_primitive_int_op::ser_primitive_int_op_http_error(&self)
|
1006 + | {
|
1007 + | Ok(mut response) => {
|
1008 + | response.extensions_mut().insert(
|
1009 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1010 + | self.name(),
|
1011 + | ),
|
1012 + | );
|
1013 + | response
|
1014 + | }
|
1015 + | Err(e) => {
|
1016 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1017 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1018 + | }
|
1019 + | }
|
1020 + | }
|
1021 + | }
|
1022 + |
|
1023 + | #[allow(unreachable_code, unused_variables)]
|
1024 + | #[cfg(test)]
|
1025 + | mod primitive_int_op_test {
|
1026 + |
|
1027 + | /// Upper case error modeled lower case.
|
1028 + | /// Test ID: ServiceLevelErrorServer
|
1029 + | #[::tokio::test]
|
1030 + | #[::tracing_test::traced_test]
|
1031 + | async fn service_level_error_server_response() {
|
1032 + | let output = crate::error::ExtraError {};
|
1033 + | let output = crate::error::PrimitiveIntOpError::ExtraError(output);
|
1034 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1035 + | let http_response = output.into_response();
|
1036 + | ::pretty_assertions::assert_eq!(
|
1037 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1038 + | http_response.status()
|
1039 + | );
|
1040 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1041 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1042 + | http_response.headers(),
|
1043 + | expected_headers,
|
1044 + | ));
|
1045 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1046 + | .await
|
1047 + | .expect("unable to extract body to bytes");
|
1048 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1049 + | &body,
|
1050 + | "{}",
|
1051 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1052 + | ));
|
1053 + | }
|
1054 + | }
|
1055 + |
|
1056 + | ::pin_project_lite::pin_project! {
|
1057 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1058 + | /// [`MapWithEnumKeyOpInput`](crate::input::MapWithEnumKeyOpInput) using modelled bindings.
|
1059 + | pub struct MapWithEnumKeyOpInputFuture {
|
1060 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MapWithEnumKeyOpInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1061 + | }
|
1062 + | }
|
1063 + |
|
1064 + | impl std::future::Future for MapWithEnumKeyOpInputFuture {
|
1065 + | type Output = Result<
|
1066 + | crate::input::MapWithEnumKeyOpInput,
|
1067 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1068 + | >;
|
1069 + |
|
1070 + | fn poll(
|
1071 + | self: std::pin::Pin<&mut Self>,
|
1072 + | cx: &mut std::task::Context<'_>,
|
1073 + | ) -> std::task::Poll<Self::Output> {
|
1074 + | let this = self.project();
|
1075 + | this.inner.as_mut().poll(cx)
|
1076 + | }
|
1077 + | }
|
1078 + |
|
1079 + | impl<B>
|
1080 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1081 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1082 + | B,
|
1083 + | > for crate::input::MapWithEnumKeyOpInput
|
1084 + | where
|
1085 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1086 + | B: 'static,
|
1087 + |
|
1088 + | B::Data: Send,
|
1089 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1090 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1091 + | {
|
1092 + | type Rejection =
|
1093 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1094 + | type Future = MapWithEnumKeyOpInputFuture;
|
1095 + |
|
1096 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1097 + | let fut = async move {
|
1098 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1099 + | request.headers(),
|
1100 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1101 + | ) {
|
1102 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1103 + | }
|
1104 + | crate::protocol_serde::shape_map_with_enum_key_op::de_map_with_enum_key_op_http_request(
|
1105 + | request,
|
1106 + | )
|
1107 + | .await
|
1108 + | };
|
1109 + | use ::futures_util::future::TryFutureExt;
|
1110 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1111 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1112 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1113 + | });
|
1114 + | MapWithEnumKeyOpInputFuture {
|
1115 + | inner: Box::pin(fut),
|
1116 + | }
|
1117 + | }
|
1118 + | }
|
1119 + | impl
|
1120 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1121 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1122 + | > for crate::output::MapWithEnumKeyOpOutput
|
1123 + | {
|
1124 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1125 + | match crate::protocol_serde::shape_map_with_enum_key_op::ser_map_with_enum_key_op_http_response(self) {
|
1126 + | Ok(response) => response,
|
1127 + | Err(e) => {
|
1128 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1129 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1130 + | }
|
1131 + | }
|
1132 + | }
|
1133 + | }
|
1134 + | impl
|
1135 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1136 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1137 + | > for crate::error::MapWithEnumKeyOpError
|
1138 + | {
|
1139 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1140 + | match crate::protocol_serde::shape_map_with_enum_key_op::ser_map_with_enum_key_op_http_error(
|
1141 + | &self,
|
1142 + | ) {
|
1143 + | Ok(mut response) => {
|
1144 + | response.extensions_mut().insert(
|
1145 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1146 + | self.name(),
|
1147 + | ),
|
1148 + | );
|
1149 + | response
|
1150 + | }
|
1151 + | Err(e) => {
|
1152 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1153 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1154 + | }
|
1155 + | }
|
1156 + | }
|
1157 + | }
|
1158 + |
|
1159 + | #[allow(unreachable_code, unused_variables)]
|
1160 + | #[cfg(test)]
|
1161 + | mod map_with_enum_key_op_test {
|
1162 + |
|
1163 + | /// Test ID: MapWithEnumKeyRequest
|
1164 + | #[::tokio::test]
|
1165 + | #[::tracing_test::traced_test]
|
1166 + | async fn map_with_enum_key_request_request() {
|
1167 + | #[allow(unused_mut)]
|
1168 + | let mut http_request = ::http::Request::builder()
|
1169 + | .uri("/map-with-enum-key")
|
1170 + | .method("POST")
|
1171 + | .header("Content-Type", "application/json")
|
1172 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1173 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1174 + | "{\"map\":{\"enumvalue\":\"something\"}}".as_bytes(),
|
1175 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1176 + | )),
|
1177 + | ))
|
1178 + | .unwrap();
|
1179 + | #[allow(unused_mut)]
|
1180 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1181 + | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
1182 + | let service =
|
1183 + | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
1184 + | .map_with_enum_key_op(move |input: crate::input::MapWithEnumKeyOpInput| {
|
1185 + | let sender = sender.clone();
|
1186 + | async move {
|
1187 + | let result = {
|
1188 + | let expected = crate::input::MapWithEnumKeyOpInput {
|
1189 + | map: ::std::option::Option::Some({
|
1190 + | let mut ret = ::std::collections::HashMap::new();
|
1191 + | ret.insert(
|
1192 + | "enumvalue"
|
1193 + | .parse::<crate::model::StringEnum>()
|
1194 + | .expect("static value validated to member"),
|
1195 + | "something".to_owned(),
|
1196 + | );
|
1197 + | ret
|
1198 + | }),
|
1199 + | };
|
1200 + | ::pretty_assertions::assert_eq!(input, expected);
|
1201 + | let output = crate::output::MapWithEnumKeyOpOutput {
|
1202 + | map: ::std::option::Option::None,
|
1203 + | };
|
1204 + | Ok(output)
|
1205 + | };
|
1206 + | sender.send(()).await.expect("receiver dropped early");
|
1207 + | result
|
1208 + | }
|
1209 + | })
|
1210 + | .build_unchecked();
|
1211 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1212 + | .await
|
1213 + | .expect("unable to make an HTTP request");
|
1214 + | assert!(
|
1215 + | receiver.recv().await.is_some(),
|
1216 + | "we expected operation handler to be invoked but it was not entered"
|
1217 + | );
|
1218 + | }
|
1219 + | /// Test ID: MapWithEnumKeyResponse
|
1220 + | #[::tokio::test]
|
1221 + | #[::tracing_test::traced_test]
|
1222 + | async fn map_with_enum_key_response_response() {
|
1223 + | let output = crate::output::MapWithEnumKeyOpOutput {
|
1224 + | map: ::std::option::Option::Some({
|
1225 + | let mut ret = ::std::collections::HashMap::new();
|
1226 + | ret.insert(
|
1227 + | "enumvalue"
|
1228 + | .parse::<crate::model::StringEnum>()
|
1229 + | .expect("static value validated to member"),
|
1230 + | "something".to_owned(),
|
1231 + | );
|
1232 + | ret
|
1233 + | }),
|
1234 + | };
|
1235 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1236 + | let http_response = output.into_response();
|
1237 + | ::pretty_assertions::assert_eq!(
|
1238 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1239 + | http_response.status()
|
1240 + | );
|
1241 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1242 + | .await
|
1243 + | .expect("unable to extract body to bytes");
|
1244 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1245 + | &body,
|
1246 + | "{\"map\":{\"enumvalue\":\"something\"}}",
|
1247 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1248 + | ));
|
1249 + | }
|
1250 + |
|
1251 + | /// Upper case error modeled lower case.
|
1252 + | /// Test ID: ServiceLevelErrorServer
|
1253 + | #[::tokio::test]
|
1254 + | #[::tracing_test::traced_test]
|
1255 + | async fn service_level_error_server_response() {
|
1256 + | let output = crate::error::ExtraError {};
|
1257 + | let output = crate::error::MapWithEnumKeyOpError::ExtraError(output);
|
1258 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1259 + | let http_response = output.into_response();
|
1260 + | ::pretty_assertions::assert_eq!(
|
1261 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1262 + | http_response.status()
|
1263 + | );
|
1264 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1265 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1266 + | http_response.headers(),
|
1267 + | expected_headers,
|
1268 + | ));
|
1269 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1270 + | .await
|
1271 + | .expect("unable to extract body to bytes");
|
1272 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1273 + | &body,
|
1274 + | "{}",
|
1275 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1276 + | ));
|
1277 + | }
|
1278 + | }
|
1279 + |
|
1280 + | ::pin_project_lite::pin_project! {
|
1281 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1282 + | /// [`StatusResponseInput`](crate::input::StatusResponseInput) using modelled bindings.
|
1283 + | pub struct StatusResponseInputFuture {
|
1284 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StatusResponseInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1285 + | }
|
1286 + | }
|
1287 + |
|
1288 + | impl std::future::Future for StatusResponseInputFuture {
|
1289 + | type Output = Result<
|
1290 + | crate::input::StatusResponseInput,
|
1291 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1292 + | >;
|
1293 + |
|
1294 + | fn poll(
|
1295 + | self: std::pin::Pin<&mut Self>,
|
1296 + | cx: &mut std::task::Context<'_>,
|
1297 + | ) -> std::task::Poll<Self::Output> {
|
1298 + | let this = self.project();
|
1299 + | this.inner.as_mut().poll(cx)
|
1300 + | }
|
1301 + | }
|
1302 + |
|
1303 + | impl<B>
|
1304 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1305 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1306 + | B,
|
1307 + | > for crate::input::StatusResponseInput
|
1308 + | where
|
1309 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1310 + | B: 'static,
|
1311 + |
|
1312 + | B::Data: Send,
|
1313 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1314 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1315 + | {
|
1316 + | type Rejection =
|
1317 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1318 + | type Future = StatusResponseInputFuture;
|
1319 + |
|
1320 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1321 + | let fut = async move {
|
1322 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1323 + | request.headers(),
|
1324 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1325 + | ) {
|
1326 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1327 + | }
|
1328 + | crate::protocol_serde::shape_status_response::de_status_response_http_request(request)
|
1329 + | .await
|
1330 + | };
|
1331 + | use ::futures_util::future::TryFutureExt;
|
1332 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1333 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1334 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1335 + | });
|
1336 + | StatusResponseInputFuture {
|
1337 + | inner: Box::pin(fut),
|
1338 + | }
|
1339 + | }
|
1340 + | }
|
1341 + | impl
|
1342 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1343 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1344 + | > for crate::output::StatusResponseOutput
|
1345 + | {
|
1346 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1347 + | match crate::protocol_serde::shape_status_response::ser_status_response_http_response(self)
|
1348 + | {
|
1349 + | Ok(response) => response,
|
1350 + | Err(e) => {
|
1351 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1352 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1353 + | }
|
1354 + | }
|
1355 + | }
|
1356 + | }
|
1357 + | impl
|
1358 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1359 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1360 + | > for crate::error::StatusResponseError
|
1361 + | {
|
1362 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1363 + | match crate::protocol_serde::shape_status_response::ser_status_response_http_error(&self) {
|
1364 + | Ok(mut response) => {
|
1365 + | response.extensions_mut().insert(
|
1366 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1367 + | self.name(),
|
1368 + | ),
|
1369 + | );
|
1370 + | response
|
1371 + | }
|
1372 + | Err(e) => {
|
1373 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1374 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1375 + | }
|
1376 + | }
|
1377 + | }
|
1378 + | }
|
1379 + |
|
1380 + | #[allow(unreachable_code, unused_variables)]
|
1381 + | #[cfg(test)]
|
1382 + | mod status_response_test {
|
1383 + |
|
1384 + | /// Upper case error modeled lower case.
|
1385 + | /// Test ID: ServiceLevelErrorServer
|
1386 + | #[::tokio::test]
|
1387 + | #[::tracing_test::traced_test]
|
1388 + | async fn service_level_error_server_response() {
|
1389 + | let output = crate::error::ExtraError {};
|
1390 + | let output = crate::error::StatusResponseError::ExtraError(output);
|
1391 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1392 + | let http_response = output.into_response();
|
1393 + | ::pretty_assertions::assert_eq!(
|
1394 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1395 + | http_response.status()
|
1396 + | );
|
1397 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1398 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1399 + | http_response.headers(),
|
1400 + | expected_headers,
|
1401 + | ));
|
1402 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1403 + | .await
|
1404 + | .expect("unable to extract body to bytes");
|
1405 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1406 + | &body,
|
1407 + | "{}",
|
1408 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1409 + | ));
|
1410 + | }
|
1411 + | }
|
1412 + |
|
1413 + | ::pin_project_lite::pin_project! {
|
1414 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1415 + | /// [`EnumQueryInput`](crate::input::EnumQueryInput) using modelled bindings.
|
1416 + | pub struct EnumQueryInputFuture {
|
1417 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EnumQueryInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1418 + | }
|
1419 + | }
|
1420 + |
|
1421 + | impl std::future::Future for EnumQueryInputFuture {
|
1422 + | type Output = Result<
|
1423 + | crate::input::EnumQueryInput,
|
1424 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1425 + | >;
|
1426 + |
|
1427 + | fn poll(
|
1428 + | self: std::pin::Pin<&mut Self>,
|
1429 + | cx: &mut std::task::Context<'_>,
|
1430 + | ) -> std::task::Poll<Self::Output> {
|
1431 + | let this = self.project();
|
1432 + | this.inner.as_mut().poll(cx)
|
1433 + | }
|
1434 + | }
|
1435 + |
|
1436 + | impl<B>
|
1437 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1438 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1439 + | B,
|
1440 + | > for crate::input::EnumQueryInput
|
1441 + | where
|
1442 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1443 + | B: 'static,
|
1444 + |
|
1445 + | B::Data: Send,
|
1446 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1447 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1448 + | {
|
1449 + | type Rejection =
|
1450 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1451 + | type Future = EnumQueryInputFuture;
|
1452 + |
|
1453 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1454 + | let fut = async move {
|
1455 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1456 + | request.headers(),
|
1457 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1458 + | ) {
|
1459 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1460 + | }
|
1461 + | crate::protocol_serde::shape_enum_query::de_enum_query_http_request(request).await
|
1462 + | };
|
1463 + | use ::futures_util::future::TryFutureExt;
|
1464 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1465 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1466 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1467 + | });
|
1468 + | EnumQueryInputFuture {
|
1469 + | inner: Box::pin(fut),
|
1470 + | }
|
1471 + | }
|
1472 + | }
|
1473 + | impl
|
1474 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1475 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1476 + | > for crate::output::EnumQueryOutput
|
1477 + | {
|
1478 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1479 + | match crate::protocol_serde::shape_enum_query::ser_enum_query_http_response(self) {
|
1480 + | Ok(response) => response,
|
1481 + | Err(e) => {
|
1482 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1483 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1484 + | }
|
1485 + | }
|
1486 + | }
|
1487 + | }
|
1488 + | impl
|
1489 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1490 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1491 + | > for crate::error::EnumQueryError
|
1492 + | {
|
1493 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1494 + | match crate::protocol_serde::shape_enum_query::ser_enum_query_http_error(&self) {
|
1495 + | Ok(mut response) => {
|
1496 + | response.extensions_mut().insert(
|
1497 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1498 + | self.name(),
|
1499 + | ),
|
1500 + | );
|
1501 + | response
|
1502 + | }
|
1503 + | Err(e) => {
|
1504 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1505 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1506 + | }
|
1507 + | }
|
1508 + | }
|
1509 + | }
|
1510 + |
|
1511 + | #[allow(unreachable_code, unused_variables)]
|
1512 + | #[cfg(test)]
|
1513 + | mod enum_query_test {
|
1514 + |
|
1515 + | /// Test ID: EnumQueryRequest
|
1516 + | #[::tokio::test]
|
1517 + | #[::tracing_test::traced_test]
|
1518 + | async fn enum_query_request_request() {
|
1519 + | #[allow(unused_mut)]
|
1520 + | let mut http_request = ::http::Request::builder()
|
1521 + | .uri("/foo/enumvalue")
|
1522 + | .method("GET")
|
1523 + | .body(::aws_smithy_legacy_http_server::body::Body::empty())
|
1524 + | .unwrap();
|
1525 + | #[allow(unused_mut)]
|
1526 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1527 + | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
1528 + | let service =
|
1529 + | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
1530 + | .enum_query(move |input: crate::input::EnumQueryInput| {
|
1531 + | let sender = sender.clone();
|
1532 + | async move {
|
1533 + | let result = {
|
1534 + | let expected = crate::input::EnumQueryInput {
|
1535 + | r#enum: "enumvalue"
|
1536 + | .parse::<crate::model::StringEnum>()
|
1537 + | .expect("static value validated to member"),
|
1538 + | };
|
1539 + | ::pretty_assertions::assert_eq!(input, expected);
|
1540 + | let output = crate::output::EnumQueryOutput {};
|
1541 + | Ok(output)
|
1542 + | };
|
1543 + | sender.send(()).await.expect("receiver dropped early");
|
1544 + | result
|
1545 + | }
|
1546 + | })
|
1547 + | .build_unchecked();
|
1548 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1549 + | .await
|
1550 + | .expect("unable to make an HTTP request");
|
1551 + | assert!(
|
1552 + | receiver.recv().await.is_some(),
|
1553 + | "we expected operation handler to be invoked but it was not entered"
|
1554 + | );
|
1555 + | }
|
1556 + |
|
1557 + | /// Upper case error modeled lower case.
|
1558 + | /// Test ID: ServiceLevelErrorServer
|
1559 + | #[::tokio::test]
|
1560 + | #[::tracing_test::traced_test]
|
1561 + | async fn service_level_error_server_response() {
|
1562 + | let output = crate::error::ExtraError {};
|
1563 + | let output = crate::error::EnumQueryError::ExtraError(output);
|
1564 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1565 + | let http_response = output.into_response();
|
1566 + | ::pretty_assertions::assert_eq!(
|
1567 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1568 + | http_response.status()
|
1569 + | );
|
1570 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1571 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1572 + | http_response.headers(),
|
1573 + | expected_headers,
|
1574 + | ));
|
1575 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1576 + | .await
|
1577 + | .expect("unable to extract body to bytes");
|
1578 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1579 + | &body,
|
1580 + | "{}",
|
1581 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1582 + | ));
|
1583 + | }
|
1584 + | }
|
1585 + |
|
1586 + | ::pin_project_lite::pin_project! {
|
1587 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1588 + | /// [`PrimitiveIntHeaderInput`](crate::input::PrimitiveIntHeaderInput) using modelled bindings.
|
1589 + | pub struct PrimitiveIntHeaderInputFuture {
|
1590 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PrimitiveIntHeaderInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1591 + | }
|
1592 + | }
|
1593 + |
|
1594 + | impl std::future::Future for PrimitiveIntHeaderInputFuture {
|
1595 + | type Output = Result<
|
1596 + | crate::input::PrimitiveIntHeaderInput,
|
1597 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1598 + | >;
|
1599 + |
|
1600 + | fn poll(
|
1601 + | self: std::pin::Pin<&mut Self>,
|
1602 + | cx: &mut std::task::Context<'_>,
|
1603 + | ) -> std::task::Poll<Self::Output> {
|
1604 + | let this = self.project();
|
1605 + | this.inner.as_mut().poll(cx)
|
1606 + | }
|
1607 + | }
|
1608 + |
|
1609 + | impl<B>
|
1610 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1611 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1612 + | B,
|
1613 + | > for crate::input::PrimitiveIntHeaderInput
|
1614 + | where
|
1615 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1616 + | B: 'static,
|
1617 + |
|
1618 + | B::Data: Send,
|
1619 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1620 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1621 + | {
|
1622 + | type Rejection =
|
1623 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1624 + | type Future = PrimitiveIntHeaderInputFuture;
|
1625 + |
|
1626 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1627 + | let fut = async move {
|
1628 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1629 + | request.headers(),
|
1630 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1631 + | ) {
|
1632 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1633 + | }
|
1634 + | crate::protocol_serde::shape_primitive_int_header::de_primitive_int_header_http_request(
|
1635 + | request,
|
1636 + | )
|
1637 + | .await
|
1638 + | };
|
1639 + | use ::futures_util::future::TryFutureExt;
|
1640 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1641 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1642 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1643 + | });
|
1644 + | PrimitiveIntHeaderInputFuture {
|
1645 + | inner: Box::pin(fut),
|
1646 + | }
|
1647 + | }
|
1648 + | }
|
1649 + | impl
|
1650 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1651 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1652 + | > for crate::output::PrimitiveIntHeaderOutput
|
1653 + | {
|
1654 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1655 + | match crate::protocol_serde::shape_primitive_int_header::ser_primitive_int_header_http_response(self) {
|
1656 + | Ok(response) => response,
|
1657 + | Err(e) => {
|
1658 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1659 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1660 + | }
|
1661 + | }
|
1662 + | }
|
1663 + | }
|
1664 + | impl
|
1665 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1666 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1667 + | > for crate::error::PrimitiveIntHeaderError
|
1668 + | {
|
1669 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1670 + | match crate::protocol_serde::shape_primitive_int_header::ser_primitive_int_header_http_error(
|
1671 + | &self,
|
1672 + | ) {
|
1673 + | Ok(mut response) => {
|
1674 + | response.extensions_mut().insert(
|
1675 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1676 + | self.name(),
|
1677 + | ),
|
1678 + | );
|
1679 + | response
|
1680 + | }
|
1681 + | Err(e) => {
|
1682 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1683 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1684 + | }
|
1685 + | }
|
1686 + | }
|
1687 + | }
|
1688 + |
|
1689 + | #[allow(unreachable_code, unused_variables)]
|
1690 + | #[cfg(test)]
|
1691 + | mod primitive_int_header_test {
|
1692 + |
|
1693 + | /// Test ID: DeserPrimitiveHeader
|
1694 + | #[::tokio::test]
|
1695 + | #[::tracing_test::traced_test]
|
1696 + | async fn deser_primitive_header_response() {
|
1697 + | let output = crate::output::PrimitiveIntHeaderOutput { field: 123 };
|
1698 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1699 + | let http_response = output.into_response();
|
1700 + | ::pretty_assertions::assert_eq!(
|
1701 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1702 + | http_response.status()
|
1703 + | );
|
1704 + | let expected_headers = [("x-field", "123")];
|
1705 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1706 + | http_response.headers(),
|
1707 + | expected_headers,
|
1708 + | ));
|
1709 + | }
|
1710 + | /// Test ID: DeserPrimitiveHeaderMissing
|
1711 + | #[::tokio::test]
|
1712 + | #[::tracing_test::traced_test]
|
1713 + | async fn deser_primitive_header_missing_response() {
|
1714 + | let output = crate::output::PrimitiveIntHeaderOutput { field: 0 };
|
1715 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1716 + | let http_response = output.into_response();
|
1717 + | ::pretty_assertions::assert_eq!(
|
1718 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1719 + | http_response.status()
|
1720 + | );
|
1721 + | }
|
1722 + |
|
1723 + | /// Upper case error modeled lower case.
|
1724 + | /// Test ID: ServiceLevelErrorServer
|
1725 + | #[::tokio::test]
|
1726 + | #[::tracing_test::traced_test]
|
1727 + | async fn service_level_error_server_response() {
|
1728 + | let output = crate::error::ExtraError {};
|
1729 + | let output = crate::error::PrimitiveIntHeaderError::ExtraError(output);
|
1730 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1731 + | let http_response = output.into_response();
|
1732 + | ::pretty_assertions::assert_eq!(
|
1733 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1734 + | http_response.status()
|
1735 + | );
|
1736 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1737 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1738 + | http_response.headers(),
|
1739 + | expected_headers,
|
1740 + | ));
|
1741 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1742 + | .await
|
1743 + | .expect("unable to extract body to bytes");
|
1744 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1745 + | &body,
|
1746 + | "{}",
|
1747 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1748 + | ));
|
1749 + | }
|
1750 + | }
|
1751 + |
|
1752 + | ::pin_project_lite::pin_project! {
|
1753 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1754 + | /// [`StringPayloadInput`](crate::input::StringPayloadInput) using modelled bindings.
|
1755 + | pub struct StringPayloadInputFuture {
|
1756 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StringPayloadInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1757 + | }
|
1758 + | }
|
1759 + |
|
1760 + | impl std::future::Future for StringPayloadInputFuture {
|
1761 + | type Output = Result<
|
1762 + | crate::input::StringPayloadInput,
|
1763 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1764 + | >;
|
1765 + |
|
1766 + | fn poll(
|
1767 + | self: std::pin::Pin<&mut Self>,
|
1768 + | cx: &mut std::task::Context<'_>,
|
1769 + | ) -> std::task::Poll<Self::Output> {
|
1770 + | let this = self.project();
|
1771 + | this.inner.as_mut().poll(cx)
|
1772 + | }
|
1773 + | }
|
1774 + |
|
1775 + | impl<B>
|
1776 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1777 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1778 + | B,
|
1779 + | > for crate::input::StringPayloadInput
|
1780 + | where
|
1781 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1782 + | B: 'static,
|
1783 + |
|
1784 + | B::Data: Send,
|
1785 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1786 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1787 + | {
|
1788 + | type Rejection =
|
1789 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1790 + | type Future = StringPayloadInputFuture;
|
1791 + |
|
1792 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1793 + | let fut = async move {
|
1794 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1795 + | request.headers(),
|
1796 + | &crate::mimes::CONTENT_TYPE_TEXT_PLAIN,
|
1797 + | ) {
|
1798 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1799 + | }
|
1800 + | crate::protocol_serde::shape_string_payload::de_string_payload_http_request(request)
|
1801 + | .await
|
1802 + | };
|
1803 + | use ::futures_util::future::TryFutureExt;
|
1804 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1805 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1806 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1807 + | });
|
1808 + | StringPayloadInputFuture {
|
1809 + | inner: Box::pin(fut),
|
1810 + | }
|
1811 + | }
|
1812 + | }
|
1813 + | impl
|
1814 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1815 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1816 + | > for crate::output::StringPayloadOutput
|
1817 + | {
|
1818 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1819 + | match crate::protocol_serde::shape_string_payload::ser_string_payload_http_response(self) {
|
1820 + | Ok(response) => response,
|
1821 + | Err(e) => {
|
1822 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1823 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1824 + | }
|
1825 + | }
|
1826 + | }
|
1827 + | }
|
1828 + | impl
|
1829 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1830 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1831 + | > for crate::error::StringPayloadError
|
1832 + | {
|
1833 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1834 + | match crate::protocol_serde::shape_string_payload::ser_string_payload_http_error(&self) {
|
1835 + | Ok(mut response) => {
|
1836 + | response.extensions_mut().insert(
|
1837 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1838 + | self.name(),
|
1839 + | ),
|
1840 + | );
|
1841 + | response
|
1842 + | }
|
1843 + | Err(e) => {
|
1844 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1845 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1846 + | }
|
1847 + | }
|
1848 + | }
|
1849 + | }
|
1850 + |
|
1851 + | #[allow(unreachable_code, unused_variables)]
|
1852 + | #[cfg(test)]
|
1853 + | mod string_payload_test {
|
1854 + |
|
1855 + | /// Test ID: StringPayload
|
1856 + | #[::tokio::test]
|
1857 + | #[::tracing_test::traced_test]
|
1858 + | async fn string_payload_request() {
|
1859 + | #[allow(unused_mut)]
|
1860 + | let mut http_request = ::http::Request::builder()
|
1861 + | .uri("/StringPayload")
|
1862 + | .method("POST")
|
1863 + | .header("Content-Type", "text/plain")
|
1864 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1865 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1866 + | "rawstring".as_bytes(),
|
1867 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1868 + | )),
|
1869 + | ))
|
1870 + | .unwrap();
|
1871 + | #[allow(unused_mut)]
|
1872 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1873 + | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
1874 + | let service =
|
1875 + | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
1876 + | .string_payload(move |input: crate::input::StringPayloadInput| {
|
1877 + | let sender = sender.clone();
|
1878 + | async move {
|
1879 + | let result = {
|
1880 + | let expected = crate::input::StringPayloadInput {
|
1881 + | payload: ::std::option::Option::Some("rawstring".to_owned()),
|
1882 + | };
|
1883 + | ::pretty_assertions::assert_eq!(input, expected);
|
1884 + | let output = crate::output::StringPayloadOutput {
|
1885 + | payload: ::std::option::Option::None,
|
1886 + | };
|
1887 + | Ok(output)
|
1888 + | };
|
1889 + | sender.send(()).await.expect("receiver dropped early");
|
1890 + | result
|
1891 + | }
|
1892 + | })
|
1893 + | .build_unchecked();
|
1894 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1895 + | .await
|
1896 + | .expect("unable to make an HTTP request");
|
1897 + | assert!(
|
1898 + | receiver.recv().await.is_some(),
|
1899 + | "we expected operation handler to be invoked but it was not entered"
|
1900 + | );
|
1901 + | }
|
1902 + |
|
1903 + | /// Upper case error modeled lower case.
|
1904 + | /// Test ID: ServiceLevelErrorServer
|
1905 + | #[::tokio::test]
|
1906 + | #[::tracing_test::traced_test]
|
1907 + | async fn service_level_error_server_response() {
|
1908 + | let output = crate::error::ExtraError {};
|
1909 + | let output = crate::error::StringPayloadError::ExtraError(output);
|
1910 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1911 + | let http_response = output.into_response();
|
1912 + | ::pretty_assertions::assert_eq!(
|
1913 + | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1914 + | http_response.status()
|
1915 + | );
|
1916 + | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1917 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1918 + | http_response.headers(),
|
1919 + | expected_headers,
|
1920 + | ));
|
1921 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1922 + | .await
|
1923 + | .expect("unable to extract body to bytes");
|
1924 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1925 + | &body,
|
1926 + | "{}",
|
1927 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1928 + | ));
|
1929 + | }
|
1930 + | }
|