add route parameters

This commit is contained in:
Brian Gough 2016-09-02 14:03:38 +01:00
parent 9bc7594226
commit 8d14f8f7f0

View file

@ -27,6 +27,18 @@ app.configure ->
DispatchManager.createAndStartDispatchers(Settings.dispatcherCount || 10)
app.param 'project_id', (req, res, next, project_id) ->
if project_id?.match /^[0-9a-f]{24}$/
next()
else
next new Error("invalid project id")
app.param 'doc_id', (req, res, next, doc_id) ->
if doc_id?.match /^[0-9a-f]{24}$/
next()
else
next new Error("invalid doc id")
app.get '/project/:project_id/doc/:doc_id', HttpController.getDoc
app.post '/project/:project_id/doc/:doc_id', HttpController.setDoc
app.post '/project/:project_id/doc/:doc_id/flush', HttpController.flushDocIfLoaded