-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.rs
More file actions
52 lines (40 loc) · 1.54 KB
/
lib.rs
File metadata and controls
52 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
use aws_lambda_events::apigw::ApiGatewayProxyResponse;
// These are documented public exports since either the generated `Api` traits or the `Middleware`
// depends on them.
pub use async_trait;
pub use aws_lambda_events::apigw::ApiGatewayProxyRequestContext;
pub use aws_lambda_events::encodings::Body;
pub use aws_lambda_events::http::{HeaderMap, HeaderName};
pub use http::{Response, StatusCode};
pub use lambda_runtime::{Context as LambdaContext, LambdaEvent};
/// Error handling.
pub mod error;
pub use error::EventError;
mod middleware;
pub use middleware::{Middleware, UnauthenticatedMiddleware};
/// Request/response model-related types and re-exports.
pub mod models;
mod runtime;
pub use runtime::run_lambda;
/// HTTP response.
pub type HttpResponse = Response<Body>;
/// Serialize an [`HttpResponse`] as an [`ApiGatewayProxyResponse`].
pub fn http_response_to_apigw(response: HttpResponse) -> ApiGatewayProxyResponse {
let (parts, body) = response.into_parts();
let is_base64_encoded = matches!(body, Body::Binary(_));
ApiGatewayProxyResponse {
status_code: parts.status.as_u16() as i64,
headers: Default::default(),
multi_value_headers: parts.headers,
body: Some(body),
is_base64_encoded,
}
}
// Used by generated code. Not part of the public API. Not bound by SemVer. Each release of
// `openapi-lambda-codegen` is guaranteed to be compatible only with the identical version number
// of `openapi-lambda`.
#[doc(hidden)]
#[path = "private/mod.rs"]
pub mod __private;