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