pub async fn run(ep: impl IntoEndpoint) -> Result<(), Error> {
    let ep = Arc::new(ep.map_to_response().into_endpoint());
    lambda_http::lambda_runtime::run(handler(
        move |req: LambdaRequest, ctx: lambda_runtime::Context| {
            let ep = ep.clone();
            async move {
                let mut req: Request = from_lambda_request(req);
                req.extensions_mut().insert(Context(ctx));

                let resp = match ep.call(req).await {
                    Ok(resp) => resp,
                    Err(err) => err.as_response(),
                };

                let (parts, body) = resp.into_parts();
                let data = body
                    .into_vec()
                    .await
                    .map_err(|_| std::io::Error::new(ErrorKind::Other, "invalid request"))?;
                let mut lambda_resp = poem::http::Response::new(if data.is_empty() {
                    LambdaBody::Empty
                } else {
                    match String::from_utf8(data) {
                        Ok(data) => LambdaBody::Text(data),
                        Err(err) => LambdaBody::Binary(err.into_bytes()),
                    }
                });
                *lambda_resp.status_mut() = parts.status;
                *lambda_resp.version_mut() = parts.version;
                *lambda_resp.headers_mut() = parts.headers;
                *lambda_resp.extensions_mut() = parts.extensions;

                Ok::<_, Error>(lambda_http::IntoResponse::into_response(lambda_resp))
            }
        },
    ))
    .await
}
/// Starts the AWS Lambda runtime.
///
/// # Example
///
/// ```no_run
/// use poem::handler;
/// use poem_lambda::Error;
///
/// #[handler]
/// fn index() -> &'static str {
///     "hello"
/// }
///
/// #[tokio::main]
/// async fn main() -> Result<(), Error> {
///     poem_lambda::run(index).await
/// }
/// ```
Starts the AWS Lambda runtime.
Starts the AWS Lambda runtime .
pub async fn run(ep: impl IntoEndpoint) -> Result<(), Error> {
    let ep = Arc::new(ep.map_to_response().into_endpoint());
    lambda_http::lambda_runtime::run(handler(
        move |req: LambdaRequest, ctx: lambda_runtime::Context| {
            let ep = ep.clone();
            async move {
                let mut req: Request = from_lambda_request(req);
                req.extensions_mut().insert(Context(ctx));
                let resp = match ep.call(req).await {
                    Ok(resp) => resp,
                    Err(err) => err.as_response(),
                };
                let (parts, body) = resp.into_parts();
                let data = body
                    .into_vec()
                    .await
                    .map_err(|_| std::io::Error::new(ErrorKind::Other, "invalid request"))?;
                let mut lambda_resp = poem::http::Response::new(if data.is_empty() {
                    LambdaBody::Empty
                } else {
                    match String::from_utf8(data) {
                        Ok(data) => LambdaBody::Text(data),
                        Err(err) => LambdaBody::Binary(err.into_bytes()),
                    }
                });
                *lambda_resp.status_mut() = parts.status;
                *lambda_resp.version_mut() = parts.version;
                *lambda_resp.headers_mut() = parts.headers;
                *lambda_resp.extensions_mut() = parts.extensions;
                Ok::<_, Error>(lambda_http::IntoResponse::into_response(lambda_resp))
            }
        },
    ))
    .await
}
pub async fn run ( ep : impl IntoEndpoint ) -> Result < ( ) , Error > { let ep = Arc :: new ( ep . map_to_response ( ) . into_endpoint ( ) ) ; lambda_http :: lambda_runtime :: run ( handler ( move | req : LambdaRequest , ctx : lambda_runtime :: Context | { let ep = ep . clone ( ) ; async move { let mut req : Request = from_lambda_request ( req ) ; req . extensions_mut ( ) . insert ( Context ( ctx ) ) ; let resp = match ep . call ( req ) . await { Ok ( resp ) => resp , Err ( err ) => err . as_response ( ) , } ; let ( parts , body ) = resp . into_parts ( ) ; let data = body . into_vec ( ) . await . map_err ( | _ | std :: io :: Error :: new ( ErrorKind :: Other , " " ) ) ? ; let mut lambda_resp = poem :: http :: Response :: new ( if data . is_empty ( ) { LambdaBody :: Empty } else { match String :: from_utf8 ( data ) { Ok ( data ) => LambdaBody :: Text ( data ) , Err ( err ) => LambdaBody :: Binary ( err . into_bytes ( ) ) , } } ) ; * lambda_resp . status_mut ( ) = parts . status ; * lambda_resp . version_mut ( ) = parts . version ; * lambda_resp . headers_mut ( ) = parts . headers ; * lambda_resp . extensions_mut ( ) = parts . extensions ; Ok :: < _ , Error > ( lambda_http :: IntoResponse :: into_response ( lambda_resp ) ) } } , ) ) . await }
Starts the AWS Lambda runtime.
Starts the AWS Lambda runtime .
ep
impl IntoEndpoint
example
```no_run
use poem::handler;
use poem_lambda::Error.
` ` ` no_run use poem :: handler ; use poem_lambda :: Error .
[handler]
fn index() -> &'static str {
"hello"
}
fn index () - > & ' static str { " hello " }
[tokio::main]
async fn main() -> Result<(), Error> {
poem_lambda::run(index).await
}
```
async fn main () - > Result< () Error > { poem_lambda :: run ( index ) . await } ` ` `