[][src]Crate rocket_lamb

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.

Installation

Add the following to your Cargo.toml [dependencies]:

rocket_lamb = "0.1.0"

Usage

#![feature(proc_macro_hygiene, decl_macro)]

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);
}

Re-exports

pub use lambda_http::lambda;

Macros

lambda

A macro for starting new handler's poll for API Gateway and ALB events

Structs

RocketHandler

A Lambda handler for API Gateway events that processes requests using Rocket.