Skip to content

Blueprint

The core of a Pavex project is its Blueprint.
It's the type you'll use to define your API: routes, middlewares, error handlers, etc.

You can find the Blueprint for the demo project in the app/src/blueprint.rs file:

app/src/blueprint.rs
use crate::telemetry;
use pavex::{Blueprint, blueprint::from};

/// The main blueprint, defining all the components used in this API.
pub fn blueprint() -> Blueprint {
    let mut bp = Blueprint::new();
    // Bring into scope constructors, error handlers, configuration
    // and prebuilt types defined in the following crates
    bp.import(from![
        // Local components, defined in this crate
        crate,
        // Components defined in the `pavex` crate,
        // by the framework itself.
        pavex,
    ]);

    telemetry::instrument(&mut bp);

    bp.prefix("/api").routes(from![crate]);
    bp
}