Wildcard in Express/node.js router

后端 未结 2 1315
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-11 19:27

I would like to \"get rid\" of the router in node.js. Currently, what I have is something that looks like this:

app.get \'/thing1\', (req, res) ->
    re         


        
2条回答
  •  醉酒成梦
    2021-01-11 20:27

    From http://expressjs.com/api.html#app.VERB :

    app.get(/^(.*)$/, function(req, res, next){
      res.send(req.params[0]);
    });
    

    Working gist: https://gist.github.com/elliotf/5826944

提交回复
热议问题