lambda-router
is a simple library to help with routing http-api-gateway
requests to handlers in the same lambda that receive and return json.
Externally tagged
representations for ResultFirst make sure to create a api gateway endpoint
that is http
I am open to adding macro and library support for non http endpoints like lambda function urls but currently I do not use them.
Get started by creating a handler using the router
macro
```rust use lambda_router::router; use serde::{Serialize, Deserialize};
struct Input {}
struct Output {}
// you may want to consider using "thiserror" and "serde_with" crate to handle errors // and serialization when variants or other data structures in your error don't impl Serialize
enum MyError {}
async fn my_route(input: Input) -> Result
inside your entry point to your lambda function that gets the request you use the app
macro to automate writing the if statements that route requests to handlers
```rust use lambdahttp::{Body, Error, Request, Response}; // notfound is a fallback route that returns 404 and no body. it is provided for simple 404 responses, you can read about it below. use lambdarouter::{app, notfound};
async fn functionhandler(event: Request) -> Result
if you just want to return a simple 404 with no body when a request comes in that doesn't match anything, you can use the not_found pre-built default router used above. You can also impl your own like this:
```rust use lambda_http::{Body, Error, Request, Response};
async fn mycustom404(event: Request) -> Result