Skip to content
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

before route? #26

Open
edgar-maciel opened this issue Mar 4, 2014 · 8 comments
Open

before route? #26

edgar-maciel opened this issue Mar 4, 2014 · 8 comments
Labels

Comments

@edgar-maciel
Copy link

Hi,

have some method as before route where I can implement a logic before routing?

thank you

@jgallen23
Copy link
Owner

currently, that is not supported. Are you looking to run something before every route or before a specific route?

@edgar-maciel
Copy link
Author

Hello @jgallen23

Thanks for your quick reply.

The Intent is to implement a function to be called before all routes.

You suggest something?

@jgallen23
Copy link
Owner

sounds like a good feature. would you be willing to do a pull request?

@ramiel
Copy link

ramiel commented Mar 18, 2014

I developed the same thing, very similar to Gallen library. Maybe you're interested.
https://github.com/ramiel/Router.js
Even jgallen for a pull request of a similar functionality.

@edgar-maciel
Copy link
Author

@ramiel fantastic!

I see. I will download it and use.

Thanks

@jalet
Copy link

jalet commented May 13, 2014

I planned to add middleware for both before & after but i cant execute the tests properly. It seems like you have moved from Make to Grunt but not updated the docs?

@jgallen23
Copy link
Owner

yeah, I need to update the docs, I'll work on that

@webarthur
Copy link

Ok, I solve this using a wrapper fabric function:

  var middleware = function (fn) {
    return function () {
      console.log('Middleware in action!');
      fn.apply(null, arguments)
    }
  }

  routie({
    'path_to_route/:id': middleware(function (id) {
      // code...
      console.log('Params ok!', id)
    })
  })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants