-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mount and other middleware's, how to chain them? #81
Comments
Do you perhaps mean to do the following? let mut chain = Chain::new(mount);
// ...
Iron::new(chain).http("localhost:3000").unwrap();
To elaborate on middleware: |
To elaborate for @GildedHonour I just recently did this for a project: // macro for Router
let router = router!(
home: get "/" => handle_request,
dashboard: get "/dashboard" => with_middleware!(dashboard, [IsAuthenticated]),
logout: get "/logout" => logout
);
let mut mount = Mount::new();
mount.mount("/", router)
.mount("/user/", models::user::router())
.mount("/inventory/", models::inventory::router())
// ... etc ....
;
let mut chain = Chain::new(mount);
chain.link_around(SessionStorage::new(SignedCookieBackend::new(my_secret)));
chain.link_before(ErrorRecover);
chain.link_after(ErrorRecover);
let server = Iron::new(chain);
server.http(host).unwrap(); // models/users.rs
pub fn router() -> Router {
let mut router = Router::new();
router.post("/", create, "create_user");
router
} I think the aim is to use only one mount variable for your application/the chain. Let me know if this is clear or not 👍 |
It doesn't support Chain, right? So there's no way to do this or something like this?
The error is:
Is other words, I want to get Mount to work with other middleware's. How can I do this?
The text was updated successfully, but these errors were encountered: