Skip to content

Attributes

Attributes are a core part of Pavex's design. You'll use attributes to define every single Pavex component, from routes to middlewares:

use pavex::Response;
use pavex::get;

#[get(path = "/")] // (1)!
pub fn landing_page() -> Response {
    // [...]
}
  1. The #[pavex::get] attribute is used to define a new route for the landing page.

We will refer to an item with a Pavex attribute as an annotated item.

The API reference has an exhaustive list of all required and optional arguments for each attribute1. Nonetheless, a few mechanisms are common to all attributes:

This guide focuses on these cross-cutting concerns.


  1. Check out the reference for #[pavex::get] as an example of the documentation format.