actix / actix-web

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
https://actix.rs
Apache License 2.0
21.7k stars 1.68k forks source link

Does actix-web-codegen support attribute macros to GUARD of cusomized definition ?? #3141

Open TQLeung opened 1 year ago

TQLeung commented 1 year ago

Discussed in https://github.com/actix/actix-web/discussions/3140

Originally posted by **TQLeung** September 20, 2023 **Dos actix-web-codegen support attribute macros to GUARD of cusomized definition ??**
robjtede commented 1 year ago

Can you give me an example of the code you want to write?

TQLeung commented 1 year ago

Can you give me an example of the code you want to write? @robjtede

something like this, thanks. can be one guard or array of guard.

guard(["crate::my_gruad::TokenGuard1","crate::my_gruad::TokenGuard2"])


web::scope("/recipe")
        .service(item)

#[get("/item/{id}"), guard(["crate::my_gruad::TokenGuard1","crate::my_gruad::TokenGuard2"])]  // HERE ! ^_^
pub async fn item(
    app: web::Data<AppState>
) -> impl Responder {
    ......
}