armature-lambda
AWS Lambda runtime adapter for the Armature framework.
Features
- Lambda Runtime - Run Armature apps on Lambda
- API Gateway - HTTP event handling
- ALB - Application Load Balancer support
- Cold Start Optimization - Minimal startup time
- Layers - Shared dependencies
Installation
[]
= "0.1"
Quick Start
The runtime wraps any type that implements RequestHandler. The simplest
handler is a closure taking a LambdaRequest and returning a LambdaResponse:
use ;
async
Configuration
Use LambdaConfig (via with_config) to control logging and strip an
API Gateway stage prefix such as /prod:
use ;
let config = default
.log_requests
.log_responses
.base_path;
// `app` is any type implementing `RequestHandler`.
let runtime = new.with_config;
runtime.run.await?;
Adapting an existing application type
This crate does not convert between armature_core's HttpRequest /
HttpResponse and the Lambda event types, and there is no blanket
RequestHandler implementation for an Armature Application. What it offers is
impl_lambda_handler!, which removes the trait boilerplate around a
handle_request method you write:
use ;
impl_lambda_handler!;
async
The macro forwards the whole LambdaRequest — method, path, headers, query
string, path parameters, stage variables, and authorizer claims — so nothing is
lost on the way in, and maps status/body/headers back out (any
Display error becomes a 500).
The runtime auto-detects API Gateway (REST v1 / HTTP v2), ALB, and Lambda Function URL events — no separate constructor is required.
Headers
Request and response headers are Vec<(String, String)>, not maps, so repeated
names survive in both directions. In particular a handler can emit more than one
Set-Cookie:
ok
.header
.header;
header(..) appends; use set_header(..) to replace existing lines with the
same name. Read them back with header_value(..) (first match) or
header_values(..) (all, in order).
Build for Lambda
# Install cargo-lambda
# Build
# Deploy
License
MIT OR Apache-2.0