[−][src]Crate lambda_http
Enriches the lambda_runtime
crate with http
types targeting ALB and API Gateway proxy events.
Though ALB and API Gateway proxy events are separate Lambda triggers, they both share similar shapes that contextually map to an http request handler. From a application perspective the differences shouldn't matter. This crate abstracts over both using standard http types allowing you to focus more on your application while giving you to the flexibility to transparently use whichever http trigger suits your application's needs best.
Examples
use lambda_http::{lambda, IntoResponse, Request, RequestExt}; use lambda_runtime::{Context, error::HandlerError}; fn main() { lambda!(hello) } fn hello( request: Request, _ctx: Context ) -> Result<impl IntoResponse, HandlerError> { Ok(format!( "hello {}", request .query_string_parameters() .get("name") .unwrap_or_else(|| "stranger") )) }
You can also provide a closure directly to the lambda!
macro
use lambda_http::{lambda, Request, RequestExt}; fn main() { lambda!( |request: Request, context| Ok( format!( "hello {}", request.query_string_parameters() .get("name") .unwrap_or_else(|| "stranger") ) ) ) }
Re-exports
pub use http; |
Modules
request | ALB andAPI Gateway request types. |
Macros
lambda | A macro for starting new handler's poll for API Gateway and ALB events |
Structs
Response | Represents an HTTP response |
StrMap | A read-only view into a map of string data which may contain multiple values |
Enums
Body | Representation of http request and response bodies as supported by API Gateway and ALBs. |
Traits
Handler | Functions serving as ALB and API Gateway handlers must conform to this type. |
IntoResponse | A conversion of self into a |
RequestExt | Extentions for |
Functions
start | Creates a new |
Type Definitions
Request | Type alias for |