Expand description
The WhenActive middleware, and asking about a flag from inside a handler.
Shaped like rustlavel_rbac::Can, because it is a neighbouring
conversation: that middleware decides whether this user may see a route,
this one decides whether the route is there for them yet.
ⓘ
router.group("/checkout", |r| {
r.middleware(Authenticate::from_config(&config));
r.middleware(WhenActive::new("new-checkout"));
r.post("", place_order);
});
router.get("/search", |req: Request| async move {
// Or ask inside the handler, when the flag changes the page rather
// than removing it.
let template = if req.flag("beta-search").await? { "search.beta" } else { "search" };
Ok(Response::html(render(template)))
});Structs§
- When
Active - A route that is not there yet.
Traits§
- Flags
Ext req.flag(...)— asking about a flag from inside a handler.