actix / actix-web

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

route meta data #738

Closed GopherJ closed 5 years ago

GopherJ commented 5 years ago

Hello, do we have the ability to add meta data to route (like: require_admin: true) I would like to implement a token check middleware, differents tokens have differents rights and abilities, differents route paths require differents rights to access.

I would like to add meta info when I register a ressource and get it in handler.

fafhrd91 commented 5 years ago

middleware does not have access to concrete route. i think it is better to use extractor for this purpose. in 1.0-alpha you can assign arbitrary data to route, and you can access this data during extracting process

GopherJ commented 5 years ago

@fafhrd91 Thanks for your reply, do we have some documentations on it? Hope you a great week-end!

DoumanAsh commented 5 years ago

Brief https://actix.rs/actix-web/actix_web/struct.Route.html#method.data

RouteData is extractor

GopherJ commented 5 years ago

@DoumanAsh Thanks I will read that!