spring-macros 0.0.7

rust microservice framework
Documentation

Routing and runtime macros for spring.rs.

spring.rs Re-exports

spring.rs re-exports a version of this crate in it's entirety so you usually don't have to specify a dependency on this crate explicitly. Sometimes, however, updates are made to this crate before the spring.rs dependency is updated. Therefore, code examples here will show explicit imports. Check the latest [spring.rs attributes docs] to see which macros are re-exported.

Single Method Handler

There is a macro to set up a handler for each of the most common HTTP methods that also define additional guards and route-specific middleware.

See docs for: [GET], [POST], [PATCH], [PUT], [DELETE], [HEAD], [CONNECT], [OPTIONS], [TRACE]

# use spring_web::axum::response::IntoResponse;
# use spring_macros::get;
#[get("/test")]
async fn get_handler() -> impl IntoResponse {
"hello world"
}

Multiple Method Handlers

Similar to the single method handler macro but takes one or more arguments for the HTTP methods it should respond to. See [macro@route] macro docs.

# use spring_web::axum::response::IntoResponse;
# use spring_macros::route;
#[route("/test", method = "GET", method = "HEAD")]
async fn get_and_head_handler() -> impl IntoResponse {
"hello world"
}

Multiple Path Handlers

Acts as a wrapper for multiple single method handler macros. It takes no arguments and delegates those to the macros for the individual methods. See [macro@routes] macro docs.

# use spring_web::axum::response::IntoResponse;
# use spring_macros::routes;
#[routes]
#[get("/test")]
#[get("/test2")]
#[delete("/test")]
async fn example() -> impl IntoResponse {
"hello world"
}