e.g. I want to have a route like:
/mock/:level1/:level2/(:params)*
to match
/mock/a/b
/mock/a/b/p1
/mock/a/b/p1/p2
/mock/a/b/p1/p2/p3
and the value of params
in line 4 is p1/p2/p3
, then I can do params.split("/")
.
EDIT:
Flask.py can do this, that exactly what I want. Does it exist in express.js?
@app.route('/wcfmock/<level1>/<level2>/<level3>/<path:params>')
def catch_all(level1, level2, level3, params):
return 'You want params: %s' % params
Express handles this. From http://expressjs.com/guide.html#routing :
"/files/*"
/files/jquery.js
/files/javascripts/jquery.js
So, in your example, (in CoffeeScript)
util = require "util"
app.get '/a/b/c/*', (req, res) ->
res.json util.inspect(req.params)
assuming an application structure going to port 8080...
http://localhost:8080/a/b/c/d/e/f
will return
"[ 'd/e/f' ]"