12 unstable releases (3 breaking)

new 0.3.0 Dec 1, 2024
0.2.0 Sep 28, 2024
0.1.1 Sep 8, 2024
0.0.9 Sep 4, 2024
0.0.8 Aug 25, 2024

#1323 in Procedural macros

Download history 405/week @ 2024-08-16 255/week @ 2024-08-23 195/week @ 2024-08-30 400/week @ 2024-09-06 90/week @ 2024-09-13 50/week @ 2024-09-20 230/week @ 2024-09-27 69/week @ 2024-10-04 69/week @ 2024-10-11 67/week @ 2024-10-18 59/week @ 2024-10-25 58/week @ 2024-11-01 19/week @ 2024-11-08 56/week @ 2024-11-15 78/week @ 2024-11-22 268/week @ 2024-11-29

427 downloads per month
Used in 17 crates (5 directly)

MIT license

56KB
1.5K SLoC

macros for spring.rs.

spring.rs macros re-exports

spring-rs re-exports all macros for this crate, so you usually don't need to explicitly specify this dependency. You can view the re-exported macros at spring-rs.

Web route macros

Single Method Handler

There is a macro to set up a handler for each of the most common HTTP methods.

See docs for: [GET], [POST], [PATCH], [PUT], [DELETE], [HEAD], [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"
}

Dependencies

~215–650KB
~15K SLoC