Comments (1)
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 dohttp://localhost:300/accounts/index
this also default to index but if I dohttp://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)
- How to use midleware HOT 8
- 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
- How to add a filter in routes like you do in express ? HOT 6
- Allow sub route params to be camel case HOT 1
- Wildcard routes? HOT 1
- as option does not work as expected
- Rename the package? HOT 3
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.