pub fn start<R, B, E>(f: impl Handler<R, B, E>, runtime: Option<TokioRuntime>)
where
	B: From<Body>,
	E: Into<VercelError>,
	R: IntoResponse,
{
	// handler requires a mutable ref
	let mut func = f;
	lambda::start(
		|e: VercelEvent, _ctx: Context| {
			let req_str = e.body;
			let parse_result: Result<VercelRequest, Error> = serde_json::from_str(&req_str);
			match parse_result {
				Ok(req) => {
					debug!("Deserialized Vercel proxy request successfully");
					let request: http::Request<Body> = req.into();
					func.run(request.map(|b| b.into()))
						.map(|resp| VercelResponse::from(resp.into_response()))
						.map_err(|e| e.into())
				}
				Err(e) => {
					error!("Could not deserialize event body to VercelRequest {}", e);
					panic!("Could not deserialize event body to VercelRequest {}", e);
				}
			}
		},
		runtime,
	)
}
/// Creates a new `lambda_runtime::Runtime` and begins polling for Vercel Lambda events
///
/// # Arguments
///
/// * `f` A type that conforms to the `Handler` interface.
///
/// # Panics
/// The function panics if the Lambda environment variables are not set.
Creates a new `lambda_runtime::Runtime` and begins polling for Vercel Lambda events
Creates a new ` lambda_runtime :: Runtime ` and begins polling for Vercel Lambda events
pub fn start<R, B, E>(f: impl Handler<R, B, E>, runtime: Option<TokioRuntime>)
where
	B: From<Body>,
	E: Into<VercelError>,
	R: IntoResponse,
{
	// handler requires a mutable ref
	let mut func = f;
	lambda::start(
		|e: VercelEvent, _ctx: Context| {
			let req_str = e.body;
			let parse_result: Result<VercelRequest, Error> = serde_json::from_str(&req_str);
			match parse_result {
				Ok(req) => {
					debug!("Deserialized Vercel proxy request successfully");
					let request: http::Request<Body> = req.into();
					func.run(request.map(|b| b.into()))
						.map(|resp| VercelResponse::from(resp.into_response()))
						.map_err(|e| e.into())
				}
				Err(e) => {
					error!("Could not deserialize event body to VercelRequest {}", e);
					panic!("Could not deserialize event body to VercelRequest {}", e);
				}
			}
		},
		runtime,
	)
}
pub fn start < R , B , E > ( f : impl Handler < R , B , E > , runtime : Option < TokioRuntime > ) where B : From < Body > , E : Into < VercelError > , R : IntoResponse , { // handler requires a mutable ref let mut func = f ; lambda :: start ( | e : VercelEvent , _ctx : Context | { let req_str = e . body ; let parse_result : Result < VercelRequest , Error > = serde_json :: from_str ( & req_str ) ; match parse_result { Ok ( req ) => { debug ! ( " " ) ; let request : http :: Request < Body > = req . into ( ) ; func . run ( request . map ( | b | b . into ( ) ) ) . map ( | resp | VercelResponse :: from ( resp . into_response ( ) ) ) . map_err ( | e | e . into ( ) ) } Err ( e ) => { error ! ( " " e ) ; panic ! ( " " e ) ; } } } , runtime , ) }
Creates a new `lambda_runtime::Runtime` and begins polling for Vercel Lambda events
Creates a new ` lambda_runtime :: Runtime ` and begins polling for Vercel Lambda events
f
impl Handler<R, B, E>
runtime
Option<TokioRuntime>
f
impl Handler<R, B, E>
runtime
Option<TokioRuntime>
panics
The function panics if the Lambda environment variables are not set.
The function panics if the Lambda environment variables are not set .