use anyhow::Result;
use lambda_server::{Http, Context};
use serde::{Serialize, Deserialize};
use validator::{Validate, ValidationError};
#[derive(Deserialize, Debug, Validate)]
struct Request {
#[validate(range(min = 1))]
pub price: i32,
#[validate(range(min = 1))]
pub quantity: i32,
}
#[derive(Serialize, Debug)]
struct Response {
pub amount: i32,
}
fn handler(ctx: Context, req: Request) -> Result<Response> {
req.validate()?;
let amount = req.price * req.quantity;
Ok(Response{ amount })
}
#[tokio::main]
async fn main() -> Result<()> {
Http::run(handler).await?;
Ok(())
}
-
Notifications
You must be signed in to change notification settings - Fork 0
Experimental lambda runtime
License
mirecl/lambda-server
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Experimental lambda runtime
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published