Reviewing some Node.js Express code, I came across the following route list:
app.all('/user/:id/:task?', user.load);
app.get('/user/:id', user.view);
app.get('/user/:id/view', user.view);
app.get('/user/:id/edit', user.edit);
app.put('/user/:id/edit', user.update);
Upon testing this setup, I observed that requests for /user/:id
were actually directed to user.load
. This caught me by surprise as a newcomer to this environment.
I am curious about the purpose of :op?
in the first line, which seems to capture a more general route. I attempted to search for information on :op?
in the Express documentation but found no references.