1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | /* RustType.kt:534 */
|
3 + | #[allow(clippy::unnecessary_wraps)]
|
4 + | /* ServerHttpBoundProtocolGenerator.kt:408 */
|
5 + | pub async fn de_greeting_with_errors_http_request<B>(
|
6 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
7 + | ) -> std::result::Result<
|
8 + | crate::input::GreetingWithErrorsInput,
|
9 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
|
10 + | >
|
11 + | where
|
12 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
13 + | B::Data: Send,
|
14 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
15 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
16 + | {
|
17 + | /* ServerHttpBoundProtocolGenerator.kt:424 */
|
18 + | Ok({
|
19 + | /* RustType.kt:534 */
|
20 + | #[allow(unused_mut)]
|
21 + | /* ServerHttpBoundProtocolGenerator.kt:759 */
|
22 + | let mut input = crate::input::greeting_with_errors_input::Builder::default();
|
23 + | /* RustType.kt:534 */
|
24 + | #[allow(unused_variables)]
|
25 + | /* ServerHttpBoundProtocolGenerator.kt:764 */
|
26 + | let ::aws_smithy_runtime_api::http::RequestParts {
|
27 + | uri, headers, body, ..
|
28 + | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
29 + | /* ServerHttpBoundProtocolGenerator.kt:873 */
|
30 + | ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
|
31 + | &headers, None,
|
32 + | )?;
|
33 + | /* ServerHttpBoundProtocolGenerator.kt:896 */
|
34 + | input.build()
|
35 + | /* ServerHttpBoundProtocolGenerator.kt:424 */
|
36 + | })
|
37 + | /* ServerHttpBoundProtocolGenerator.kt:408 */
|
38 + | }
|
39 + |
|
40 + | /* RustType.kt:534 */
|
41 + | #[allow(clippy::unnecessary_wraps)]
|
42 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
43 + | pub fn ser_greeting_with_errors_http_response(
|
44 + | #[allow(unused_variables)] output: crate::output::GreetingWithErrorsOutput,
|
45 + | ) -> std::result::Result<
|
46 + | ::aws_smithy_legacy_http_server::response::Response,
|
47 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
48 + | > {
|
49 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
50 + | Ok({
|
51 + | /* RustType.kt:534 */
|
52 + | #[allow(unused_mut)]
|
53 + | /* ServerHttpBoundProtocolGenerator.kt:547 */
|
54 + | let mut builder = ::http::Response::builder();
|
55 + | /* ServerHttpBoundProtocolGenerator.kt:665 */
|
56 + | builder =
|
57 + | crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_headers(
|
58 + | &output, builder,
|
59 + | )?;
|
60 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
61 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
62 + | builder,
|
63 + | ::http::header::CONTENT_TYPE,
|
64 + | "application/json",
|
65 + | );
|
66 + | /* ServerHttpBoundProtocolGenerator.kt:718 */
|
67 + | let http_status: u16 = 200;
|
68 + | builder = builder.status(http_status);
|
69 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
70 + | let payload =
|
71 + | /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output_output(&output)?
|
72 + | /* ServerHttpBoundProtocolGenerator.kt:597 */;
|
73 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
74 + | let content_length = payload.len();
|
75 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
76 + | builder,
|
77 + | ::http::header::CONTENT_LENGTH,
|
78 + | content_length,
|
79 + | );
|
80 + | /* ServerHttpBoundProtocolGenerator.kt:603 */
|
81 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
82 + | /* ServerHttpBoundProtocolGenerator.kt:611 */
|
83 + | builder.body(body)?
|
84 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
85 + | })
|
86 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
87 + | }
|
88 + |
|
89 + | /* RustType.kt:534 */
|
90 + | #[allow(clippy::unnecessary_wraps)]
|
91 + | /* ServerHttpBoundProtocolGenerator.kt:471 */
|
92 + | pub fn ser_greeting_with_errors_http_error(
|
93 + | error: &crate::error::GreetingWithErrorsError,
|
94 + | ) -> std::result::Result<
|
95 + | ::aws_smithy_legacy_http_server::response::Response,
|
96 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
97 + | > {
|
98 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
99 + | Ok({
|
100 + | /* ServerHttpBoundProtocolGenerator.kt:492 */
|
101 + | match error {
|
102 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
103 + | crate::error::GreetingWithErrorsError::InvalidGreeting(output) => {
|
104 + | /* ServerHttpBoundProtocolGenerator.kt:501 */
|
105 + | let payload =
|
106 + | crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting_error(
|
107 + | output,
|
108 + | )?;
|
109 + | /* RustType.kt:534 */
|
110 + | #[allow(unused_mut)]
|
111 + | /* ServerHttpBoundProtocolGenerator.kt:511 */
|
112 + | let mut builder = ::http::Response::builder();
|
113 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
114 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
115 + | builder,
|
116 + | ::http::header::CONTENT_TYPE,
|
117 + | "application/json",
|
118 + | );
|
119 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
120 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
121 + | builder,
|
122 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
123 + | "InvalidGreeting",
|
124 + | );
|
125 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
126 + | let content_length = payload.len();
|
127 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
128 + | builder,
|
129 + | ::http::header::CONTENT_LENGTH,
|
130 + | content_length,
|
131 + | );
|
132 + | /* ServerHttpBoundProtocolGenerator.kt:528 */
|
133 + | builder
|
134 + | .status(400)
|
135 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
136 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
137 + | }
|
138 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
139 + | crate::error::GreetingWithErrorsError::ComplexError(output) => {
|
140 + | /* ServerHttpBoundProtocolGenerator.kt:501 */
|
141 + | let payload =
|
142 + | crate::protocol_serde::shape_complex_error::ser_complex_error_error(output)?;
|
143 + | /* RustType.kt:534 */
|
144 + | #[allow(unused_mut)]
|
145 + | /* ServerHttpBoundProtocolGenerator.kt:511 */
|
146 + | let mut builder = ::http::Response::builder();
|
147 + | /* ServerHttpBoundProtocolGenerator.kt:665 */
|
148 + | builder = crate::protocol_serde::shape_complex_error::ser_complex_error_headers(
|
149 + | output, builder,
|
150 + | )?;
|
151 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
152 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
153 + | builder,
|
154 + | ::http::header::CONTENT_TYPE,
|
155 + | "application/json",
|
156 + | );
|
157 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
158 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
159 + | builder,
|
160 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
161 + | "ComplexError",
|
162 + | );
|
163 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
164 + | let content_length = payload.len();
|
165 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
166 + | builder,
|
167 + | ::http::header::CONTENT_LENGTH,
|
168 + | content_length,
|
169 + | );
|
170 + | /* ServerHttpBoundProtocolGenerator.kt:528 */
|
171 + | builder
|
172 + | .status(403)
|
173 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
174 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
175 + | }
|
176 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
177 + | crate::error::GreetingWithErrorsError::FooError(output) => {
|
178 + | /* ServerHttpBoundProtocolGenerator.kt:501 */
|
179 + | let payload = crate::protocol_serde::shape_foo_error::ser_foo_error_error(output)?;
|
180 + | /* RustType.kt:534 */
|
181 + | #[allow(unused_mut)]
|
182 + | /* ServerHttpBoundProtocolGenerator.kt:511 */
|
183 + | let mut builder = ::http::Response::builder();
|
184 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
185 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
186 + | builder,
|
187 + | ::http::header::CONTENT_TYPE,
|
188 + | "application/json",
|
189 + | );
|
190 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
191 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
192 + | builder,
|
193 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
194 + | "FooError",
|
195 + | );
|
196 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
197 + | let content_length = payload.len();
|
198 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
199 + | builder,
|
200 + | ::http::header::CONTENT_LENGTH,
|
201 + | content_length,
|
202 + | );
|
203 + | /* ServerHttpBoundProtocolGenerator.kt:528 */
|
204 + | builder
|
205 + | .status(500)
|
206 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
207 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
208 + | } /* ServerHttpBoundProtocolGenerator.kt:492 */
|
209 + | }
|
210 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
211 + | })
|
212 + | /* ServerHttpBoundProtocolGenerator.kt:471 */
|
213 + | }
|
214 + |
|
215 + | /* HttpBindingGenerator.kt:565 */
|
216 + | pub fn ser_greeting_with_errors_headers(
|
217 + | input: &crate::output::GreetingWithErrorsOutput,
|
218 + | mut builder: ::http::response::Builder,
|
219 + | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
220 + | {
|
221 + | /* HttpBindingGenerator.kt:615 */
|
222 + | if let ::std::option::Option::Some(inner_1) = &input.greeting {
|
223 + | /* HttpBindingGenerator.kt:727 */
|
224 + | let formatted_2 = inner_1.as_str();
|
225 + | /* HttpBindingGenerator.kt:728 */
|
226 + | if !formatted_2.is_empty() {
|
227 + | /* HttpBindingGenerator.kt:729 */
|
228 + | let header_value = formatted_2;
|
229 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
230 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
231 + | "greeting",
|
232 + | format!(
|
233 + | "`{}` cannot be used as a header value: {}",
|
234 + | &header_value, err
|
235 + | ),
|
236 + | )
|
237 + | })?;
|
238 + | builder = builder.header("X-Greeting", header_value);
|
239 + | /* HttpBindingGenerator.kt:728 */
|
240 + | }
|
241 + | /* HttpBindingGenerator.kt:615 */
|
242 + | }
|
243 + | /* HttpBindingGenerator.kt:578 */
|
244 + | Ok(builder)
|
245 + | /* HttpBindingGenerator.kt:565 */
|
246 + | }
|