【发布时间】:2013-10-07 15:23:14
【问题描述】:
我需要在简单的 node.js 中等效于以下 express.js 代码,我可以在中间件中使用它。我需要根据 url 进行一些检查,并希望在自定义中间件中进行。
app.get "/api/users/:username", (req,res) ->
req.params.username
到目前为止,我有以下代码,
app.use (req,res,next)->
if url.parse(req.url,true).pathname is '/api/users/:username' #this wont be true as in the link there will be a actual username not ":username"
#my custom check that I want to apply
【问题讨论】:
标签: node.js express url-pattern