Skip to main content

Crate puerto_web

Crate puerto_web 

Source
Expand description

The HTTP shell every Puerto project shares (ADR-0017): the server with graceful shutdown, the health probes, the configuration read from the environment, CORS, the error body and bearer auth.

A generated project calls it; it never calls the project. main.rs is

ⓘ
#[tokio::main]
async fn main() -> Result<(), puerto_web::Error> {
    let config = puerto_web::Config::from_env()?;
    puerto_web::App::new(config)
        .intentar_servir(api::generado::bootstrap::construir_app)
        .await
}

and generado/bootstrap.rs — over the cableado composition root — builds the routes with rutas.

Re-exports§

pub use app::App;
pub use app::rutas;
pub use config::Config;
pub use config::ErrorConfig;
pub use health::SondaDisponibilidad;
pub use respuesta_error::IntoRespuestaError;
pub use respuesta_error::RespuestaError;

Modules§

app
The server: what main.rs starts and bootstrap.rs builds the routes for.
auth
The HTTP side of auth (ADR-0021 § 4): BearerAuth, the parameter that makes a handler authenticated, and prohibido, the answer #[requiere_rol] gives a caller without the role.
config
The application’s configuration, read once at startup from the environment (and .env).
health
Liveness and readiness probes, served outside the OpenAPI service (ADR-0008).
respuesta_error

Enums§

Error
Why the application did not start or stopped serving.

Attribute Macros§

requiere_rol
#[requiere_rol("admin")] on a handler that takes auth: BearerAuth — see auth. #[requiere_rol("admin")] on a handler that takes auth: BearerAuth: a caller without the role is answered 403 auth.prohibido before the body runs.