use netlify_lambda::{handler_fn, Context};
use serde::{Deserialize, Serialize};
pub type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
#[derive(Deserialize)]
struct Request {
command: String,
}
#[derive(Serialize)]
struct Response {
req_id: String,
msg: String,
}
#[tokio::main]
async fn main() -> Result<(), Error> {
let func = handler_fn(my_handler);
netlify_lambda::run(func).await?;
Ok(())
}
pub(crate) async fn my_handler(event: Request, ctx: Context) -> Result<Response, Error> {
let command = event.command;
let resp = Response {
req_id: ctx.request_id,
msg: format!("Command {} executed.", command),
};
Ok(resp)
}