Giter Club home page Giter Club logo

Comments (1)

1602 avatar 1602 commented on July 24, 2024

Behavior is correct because pattern for show action is matched, id=invalid-action in your case. I understand your expectations, but need to dig deeper into express routing to get solution for id constraints (only accept numeric values for example).

Will check it as soon as i get my laptop back.

Thanks!

On 24.12.2011, at 9:36, Jonathan [email protected] wrote:

Hey @1602 I noticed an issue wen routing invalid actions

If I do http://localhost:300/accounts the action of the accounts controller defaults to index, if I do http://localhost:300/accounts/index this also default to index but if I do http://localhost/accounts/invalid-action I get defaulted to the show action(which I think is weird), is this intentional or it is a bug?.

Any ideas?

Thank you!

JB

This is my test handler.

module.exports = function (app) {
   var map = new routing.Map(app, handler);    
   map.resources('accounts');  
};

function handler(ns, controller, action) {
   try {
       var ctlFile = './controllers/' + ns + controller + '_controller';
       var responseHandler =  {
           index: function (req, res) {
               res.send('IN INDEX');
           },

           show: function (req, res) {
               res.send('IN SHOW');
           },

           new: function (req, res) {
               res.send('IN NEW');
           },

           edit: function (req, res) {
               res.sed('IN EDIT');
           }

       }[action];
   } catch(e) {}
   return responseHandler || function (req, res) {
       res.send('Handler not found for ' + ns + controller + '#' + action);
   };
}

Reply to this email directly or view it on GitHub:
#2

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.