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.rsstarts andbootstrap.rsbuilds the routes for. - auth
- The HTTP side of auth (ADR-0021 § 4):
BearerAuth, the parameter that makes a handler authenticated, andprohibido, 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 takesauth: BearerAuth— seeauth.#[requiere_rol("admin")]on a handler that takesauth: BearerAuth: a caller without the role is answered403 auth.prohibidobefore the body runs.