Comments (6)
map.get('/posts', ensureLoggedIn(), posts.index);
it should work for railway routes.
On Fri, Oct 18, 2013 at 3:30 PM, Kaushik Thirthappa <
[email protected]> wrote:
In express, I can add a certain filter just to check if a User has been
logged in or not by doing something like this :-app.get('/posts', ensureLoggedIn(), posts.index);
How do i induce the ensureLoggedIn() behaviour using railway-routes ?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/26
.
from railway-routes.
as in,
map.get('/posts', ensureLoggedIn(), 'posts#index');
This should work ? Because its not really working for me. I will have to edit my handler
in this case i think.
I tried using the middleware
parameter like you have in your example app on this line which works fine. But i want some filter kinda functionality which executes on every request.
from railway-routes.
btw, i am using railway-routes
on an express app and not with compoundjs
from railway-routes.
and how do i use it with resources
?
map.resources('posts', ensureLoggedIn());
Even in this case, it loads as the middleware and not execute ensureLoggedIn()
on every request.
Any ideas ?
from railway-routes.
With resources, as per example: https://github.com/anatoliychakkaev/railway-routes-example-app/blob/master/routes.js#L9
Without resources:
map.get('/posts', 'controllerName#actionName', function middleware(req, res,next) { next() });
As described here: https://github.com/1602/railway-routes/blob/master/lib/railway_routes.js#L115
from railway-routes.
Cool, thanks.
from railway-routes.
Related Issues (17)
- How to use midleware HOT 8
- Issue with invalid controller actions HOT 1
- as option does not work as expected
- Rename the package? HOT 3
- History.md HOT 2
- Rename repository
- Wrong position for route middlewares HOT 2
- path_to for routes with optional parameters doesn't work HOT 1
- api broken
- HTTP PATCH support HOT 1
- How do I set `camelCaseHelperNames` for all namespaces and resources? HOT 1
- Access resource name in handler when using custom controller names. HOT 1
- Undocumented `state` option in `#getParams`
- Order in `only` param matters HOT 2
- Allow sub route params to be camel case HOT 1
- Wildcard routes? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from railway-routes.