Attribute Macro methods
#[methods]Expand description
A helper macro to support Pavex attributes on methods.
You must annotate the impl block with #[methods] whenever you want to add Pavex attributes
like #[get], #[request_scoped], or #[error_handler] to methods defined in that impl block.
Without #[methods], Pavex will reject the annotated methods.
§Example
use pavex::methods;
use pavex::Response;
pub struct UserService {
// [...]
};
#[methods] // Required for the macros below to work
impl UserService {
#[request_scoped]
pub fn new() -> Self {
// [...]
}
#[get(path = "/users/{id}")]
pub fn get_user(/* */) -> Result<Response, GetUserError> {
// [...]
}
#[post(path = "/users/{id}")]
pub fn create_user(/* */) -> Result<Response, CreateUserError> {
// [...]
}
}§Supported Annotations
All Pavex attributes can be attached to both methods and functions.