Giter Club home page Giter Club logo

Comments (6)

anatoliychakkaev avatar anatoliychakkaev commented on July 24, 2024

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.

ktkaushik avatar ktkaushik commented on July 24, 2024

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.

ktkaushik avatar ktkaushik commented on July 24, 2024

btw, i am using railway-routes on an express app and not with compoundjs

from railway-routes.

ktkaushik avatar ktkaushik commented on July 24, 2024

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.

1602 avatar 1602 commented on July 24, 2024

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.

ktkaushik avatar ktkaushik commented on July 24, 2024

Cool, thanks.

from railway-routes.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.