Function openapi_lambda::run_lambda

source ·
pub async fn run_lambda<F, Fut>(dispatch_event: F)
Expand description

Start the Lambda runtime to handle requests for the specified API using the specified middleware.

Example

// Replace `my_api` with the name of your crate and `backend` with the name of the module
// passed to `ApiLambda::new()`.
use my_api::backend::Api;
use my_api::backend_handler::BackendApiHandler;
use openapi_lambda::run_lambda;

#[tokio::main]
pub async fn main() {
  let api = BackendApiHandler::new(...);
  let middleware = ...; // Instantiate your middleware here.

  run_lambda(|event| api.dispatch_request(event, &middleware)).await
}