aws_lambda_router/
lib.rs

1//! # Lambda Router
2//!
3//! A lightweight, Express-like REST API routing framework for AWS Lambda functions
4//! behind CloudFront with support for middleware, authentication, and CORS.
5//!
6//! ## Features
7//! - Express-like routing with path parameters
8//! - Middleware support (auth, logging, CORS, etc.)
9//! - Automatic CORS preflight handling
10//! - Type-safe request/response handling
11//! - Path parameter extraction
12//! - Query string parsing
13//! - JSON body parsing
14//! - Error handling with proper HTTP status codes
15//!
16//! ## Example
17//! ```rust,no_run
18//! use lambda_router::{Router, Request, Response, Context};
19//! use lambda_runtime::{Error, LambdaEvent};
20//! use serde_json::Value;
21//!
22//! async fn get_user(req: Request, ctx: Context) -> Result<Response, Error> {
23//!     let user_id = req.path_param("userId").unwrap();
24//!     Ok(Response::ok(serde_json::json!({
25//!         "userId": user_id,
26//!         "name": "John Doe"
27//!     })))
28//! }
29//!
30//! #[tokio::main]
31//! async fn main() -> Result<(), Error> {
32//!     let mut router = Router::new();
33//!     
34//!     router.get("/api/users/:userId", get_user);
35//!     
36//!     lambda_runtime::run(router.into_service()).await
37//! }
38//! ```
39
40pub mod cors;
41pub mod error;
42pub mod matcher;
43pub mod middleware;
44pub mod request;
45pub mod response;
46pub mod router;
47
48// Re-export main types
49pub use cors::CorsConfig;
50pub use error::{Result, RouterError};
51pub use matcher::PathMatcher;
52pub use middleware::{Middleware, Next};
53pub use request::{Context, Request};
54pub use response::Response;
55pub use router::{Handler, HandlerFn, Router};