Skip to content

Mount and other middleware's, how to chain them? #81

Description

@GildedHonour

It doesn't support Chain, right? So there's no way to do this or something like this?

  env_logger::init().unwrap();
  let mut hbse = HandlebarsEngine::new();
  hbse.add(Box::new(DirectorySource::new("./views/", ".hbs")));
  if let Err(r) = hbse.reload() {
    panic!("{}", r.description());
  }

  let mut router = Router::new();
  router.get("/", index);

  let mut chain = Chain::new(router);
  chain.link_after(hbse);

  let mut mount = Mount::new();
  mount
    .mount("/", router)
    .mount("/css/", Static::new(Path::new("static/css/")))
    .mount("/js/", Static::new(Path::new("static/js/")))
    .mount("/img/", Static::new(Path::new("static/img/")));

  chain.link_after(mount); // --- compile error

  println!("Server running at http://localhost:3000/");
  Iron::new(mount).http("localhost:3000").unwrap();

The error is:

 error: the trait `for<'r, 'r, 'r> core::ops::Fn<(&'r mut iron::request::Request<'r, 'r>, iron::response::Response)>` is not implemented for the type `mount::mount::Mount` [E0277]
src/main.rs:58   chain.link_after(mount);

Is other words, I want to get Mount to work with other middleware's. How can I do this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions