Colon(:) used to define route param in Express/Koa.
app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params)
})
Google API design use colon as custom verb
Question: Is there a way to define a route in which I want use colon as normal character ?
Target: define a route that match PUT /tasks/1234:undelete
, and define with string instead of regexp.
You can define your route using the double colon notation and a switch statement to execute the appropriate logic based on your action.
Through trial and error, and from the express routing document guidance for treatment of $, I ended up with the following that appears to work:
app.put(‘/tasks/:id[:]action’, function (req, res) {});
If the dev team has any comment if that’s the best way, that would be great, but seems to work. Thanks!