Skip to main content

AppRuntime

Trait AppRuntime 

Source
pub trait AppRuntime {
    // Required methods
    fn run(self) -> impl Future<Output = Result<(), LambdaError>>;
    fn run_lambda(self) -> impl Future<Output = Result<(), LambdaError>>;
}
Expand description

Extensão que permite chamar .run() e .run_lambda() em App via dot-chain.

A função run detecta automaticamente o ambiente: em AWS Lambda (AWS_LAMBDA_RUNTIME_API presente), invoca lambda_http::run; em outros casos, sobe servidor HTTP local em 0.0.0.0:3000.

use serverust_core::App;
use serverust_lambda::AppRuntime;
use serverust_macros::get;

#[get("/")]
async fn hello() -> &'static str { "hello" }

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    App::new().route(hello).run().await?;
    Ok(())
}

Required Methods§

Source

fn run(self) -> impl Future<Output = Result<(), LambdaError>>

Detecta o ambiente e despacha entre Lambda e HTTP local.

Source

fn run_lambda(self) -> impl Future<Output = Result<(), LambdaError>>

Força runtime Lambda (lambda_http::run) independentemente do ambiente.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AppRuntime for App

Source§

fn run(self) -> impl Future<Output = Result<(), LambdaError>>

Source§

fn run_lambda(self) -> impl Future<Output = Result<(), LambdaError>>

Implementors§