Skip to main content

bootstrap

Macro bootstrap 

Source
macro_rules! bootstrap {
    ($body:expr) => { ... };
}
Expand description

Starts a server, naming the running build from the calling crate.

A macro rather than a function because the release string has to come from the application’s own CARGO_PKG_NAME and CARGO_PKG_VERSION, and those are resolved where the code is written. Called from inside this library — as sentry::release_name!() does — every project would report the same release, and Sentry could not tell one site’s deploys from another’s.

use webserver_base::{WebServer, WebServerError, bootstrap};

fn main() -> Result<(), WebServerError> {
    bootstrap!(|shutdown| async move { WebServer::from_env()?.run(shutdown).await })
}