lambda_runtime_api_client

Crates.iolambda_runtime_api_client
lib.rslambda_runtime_api_client
version0.11.1
sourcesrc
created_at2022-02-20 18:54:50.78835
updated_at2024-05-08 04:16:12.110056
descriptionAWS Lambda Runtime interaction API
homepage
repositoryhttps://github.com/awslabs/aws-lambda-rust-runtime
max_upload_size
id535907
size26,690
Harold Sun (bnusunny)

documentation

README

AWS Lambda Runtime API Client

Docs

lambda-runtime-api-client is a library to interact with the AWS Lambda Runtime API.

This crate provides simple building blocks to send REST request to this API. You probably don't need to use this crate directly, look at lambda_runtime and lambda_extension instead.

Example

use http::{Method, Request};
use hyper::Body;
use lambda_runtime_api_client::{build_request, Client, Error};

fn register_request(extension_name: &str, events: &[&str]) -> Result<Request<Body>, Error> {
    let events = serde_json::json!({ "events": events });

    let req = build_request()
        .method(Method::POST)
        .uri("/2020-01-01/extension/register")
        .header("Lambda-Extension-Name", extension_name)
        .body(Body::from(serde_json::to_string(&events)?))?;

    Ok(req)
}

#[tokio::main]
async fn main() -> Result<(), Error> {
    let client = Client::builder().build()?;
    let request = register_request("my_extension", &["INVOKE"])?;

    client.call(request).await
}
Commit count: 406

cargo fmt