Catch All Route

32 views
Skip to first unread message

sw.p...@gmail.com

unread,
Mar 24, 2014, 2:49:29 PM3/24/14
to action...@googlegroups.com
Hi all,

Is there a way to define a catch all route in Actionhero?

I'm using AngularJS as client in staticFile server and would like to send index.html file when the route match anything except the one with /api pattern.

I know how to send file from an action using server.processFile, but i don't know how to define the route as described to reach that action.

Evan Tahler

unread,
Mar 24, 2014, 6:24:05 PM3/24/14
to sw.p...@gmail.com, action...@googlegroups.com
I haven’t tried it, but something like the following should work.  Be sure the set rootEndpointType to ‘api’ rather than ‘file’ :

exports.routes = {
  all: [
    { path: ‘/api/action1', action: 'action1' },
{ path: ‘/api/action2', action: 'action2' },
...
    { path: '/', action: ‘catch_all' },
  ]
};

Unfortunately, setting a catch all route that matches ‘/‘ will ovveride the normal /api/actionName matching, and you will need to re-define them.  Use a grunt task to generate them or something to help.


--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages