actix-web icon indicating copy to clipboard operation
actix-web copied to clipboard

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

Open TQLeung opened this issue 2 years ago • 2 comments
trafficstars

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 ??

TQLeung avatar Sep 21 '23 01:09 TQLeung

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

robjtede avatar Sep 22 '23 07:09 robjtede

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 {
    ......
}



TQLeung avatar Sep 25 '23 08:09 TQLeung