1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_primitive_int_header_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::PrimitiveIntHeaderInput,
|
7 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
|
8 + | >
|
9 + | where
|
10 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11 + | B::Data: Send,
|
12 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
13 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
14 + | {
|
15 + | Ok({
|
16 + | #[allow(unused_mut)]
|
17 + | let mut input = crate::input::primitive_int_header_input::Builder::default();
|
18 + | #[allow(unused_variables)]
|
19 + | let ::aws_smithy_runtime_api::http::RequestParts {
|
20 + | uri, headers, body, ..
|
21 + | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
22 + | ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
|
23 + | &headers, None,
|
24 + | )?;
|
25 + | input.build()
|
26 + | })
|
27 + | }
|
28 + |
|
29 + | #[allow(clippy::unnecessary_wraps)]
|
30 + | pub fn ser_primitive_int_header_http_response(
|
31 + | #[allow(unused_variables)] output: crate::output::PrimitiveIntHeaderOutput,
|
32 + | ) -> std::result::Result<
|
33 + | ::aws_smithy_legacy_http_server::response::Response,
|
34 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
35 + | > {
|
36 + | Ok({
|
37 + | #[allow(unused_mut)]
|
38 + | let mut builder = ::http::Response::builder();
|
39 + | builder =
|
40 + | crate::protocol_serde::shape_primitive_int_header::ser_primitive_int_header_headers(
|
41 + | &output, builder,
|
42 + | )?;
|
43 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
44 + | builder,
|
45 + | ::http::header::CONTENT_TYPE,
|
46 + | "application/json",
|
47 + | );
|
48 + | let http_status: u16 = 200;
|
49 + | builder = builder.status(http_status);
|
50 + | let payload =
|
51 + | crate::protocol_serde::shape_primitive_int_header_output::ser_primitive_int_header_output_output_output(&output)?
|
52 + | ;
|
53 + | let content_length = payload.len();
|
54 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
55 + | builder,
|
56 + | ::http::header::CONTENT_LENGTH,
|
57 + | content_length,
|
58 + | );
|
59 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
60 + | builder.body(body)?
|
61 + | })
|
62 + | }
|
63 + |
|
64 + | #[allow(clippy::unnecessary_wraps)]
|
65 + | pub fn ser_primitive_int_header_http_error(
|
66 + | error: &crate::error::PrimitiveIntHeaderError,
|
67 + | ) -> std::result::Result<
|
68 + | ::aws_smithy_legacy_http_server::response::Response,
|
69 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
70 + | > {
|
71 + | Ok({
|
72 + | match error {
|
73 + | crate::error::PrimitiveIntHeaderError::ValidationException(output) => {
|
74 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
75 + | #[allow(unused_mut)]
|
76 + | let mut builder = ::http::Response::builder();
|
77 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
78 + | builder,
|
79 + | ::http::header::CONTENT_TYPE,
|
80 + | "application/json",
|
81 + | );
|
82 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
83 + | builder,
|
84 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
85 + | "ValidationException",
|
86 + | );
|
87 + | let content_length = payload.len();
|
88 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
89 + | builder,
|
90 + | ::http::header::CONTENT_LENGTH,
|
91 + | content_length,
|
92 + | );
|
93 + | builder
|
94 + | .status(400)
|
95 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
96 + | }
|
97 + | crate::error::PrimitiveIntHeaderError::ExtraError(output) => {
|
98 + | let payload =
|
99 + | crate::protocol_serde::shape_extra_error::ser_extra_error_error(output)?;
|
100 + | #[allow(unused_mut)]
|
101 + | let mut builder = ::http::Response::builder();
|
102 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
103 + | builder,
|
104 + | ::http::header::CONTENT_TYPE,
|
105 + | "application/json",
|
106 + | );
|
107 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
108 + | builder,
|
109 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
110 + | "ExtraError",
|
111 + | );
|
112 + | let content_length = payload.len();
|
113 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
114 + | builder,
|
115 + | ::http::header::CONTENT_LENGTH,
|
116 + | content_length,
|
117 + | );
|
118 + | builder
|
119 + | .status(500)
|
120 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
121 + | }
|
122 + | }
|
123 + | })
|
124 + | }
|
125 + |
|
126 + | pub fn ser_primitive_int_header_headers(
|
127 + | input: &crate::output::PrimitiveIntHeaderOutput,
|
128 + | mut builder: ::http::response::Builder,
|
129 + | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
130 + | {
|
131 + | {
|
132 + | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(input.field);
|
133 + | let formatted_1 = encoder.encode();
|
134 + | if !formatted_1.is_empty() {
|
135 + | let header_value = formatted_1;
|
136 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
137 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
138 + | "field",
|
139 + | format!(
|
140 + | "`{}` cannot be used as a header value: {}",
|
141 + | &header_value, err
|
142 + | ),
|
143 + | )
|
144 + | })?;
|
145 + | builder = builder.header("x-field", header_value);
|
146 + | }
|
147 + | }
|
148 + | Ok(builder)
|
149 + | }
|