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