Macro arc_reactor::mw [−][src]
macro_rules! mw { ($($middlewares:expr), +) => { ... }; }
Set middlewares that should be executed on a request.
Example
ⓘThis example is not tested
#![feature(proc_macro, generators, specialization, proc_macro_non_items)] #[macro_use] extern crate arc_reactor; use arc_reactor::{prelude::*, routing::Router}; fn get_main_routes() -> Router { let app_middlewares = mw![checkIfAuth]; // Feel free to use pre-configured app middleware } #[middleware(Request)] fn checkIfAuth(req: Request) { if req.body().is_empty() { return Err((401, "You need to include some data to access this route!").into()); } Ok(req) }