A crate to allow running a Rocket webserver as an AWS Lambda Function with API Gateway, built on the AWS Lambda Rust Runtime.
The function takes a request from an AWS API Gateway Proxy and converts it into a LocalRequest
to pass to Rocket. Then it will convert the response from Rocket into the response body that API Gateway understands.
This should also work with requests from an AWS Application Load Balancer, but this has not been tested.
Add the following to your Cargo.toml [dependencies]
:
toml
rocket_lamb = "0.1.0"
```rust
use rocket::routes; use rocket_lamb::{lambda, RocketHandler};
fn main() { // ignite a new Rocket as you normally world, but instead of launching it... let rocket = rocket::ignite().mount("/", routes![/* ... */]);
// ...use it to create a new RocketHandler:
let handler = RocketHandler::new(rocket).unwrap();
// then use this to fetch and handle Lambda events:
lambda!(handler);
} ```