Okay to add a route to Node.js Express while listening?

后端 未结 1 397
南方客
南方客 2021-02-19 00:14

Obviously the typical example of adding routes to express follows something like the following:

var express = require(\'express\');
var app = express();

app.get         


        
相关标签:
1条回答
  • 2021-02-19 00:49

    According to TJ (author of Express), it’s okay to add routes at runtime.

    The main gotcha is going to be that routes are evaluated in the order they were added, so routes added at runtime will have a lower precedence than routes added earlier. This may or may not matter, depending on your API design.

    0 讨论(0)
提交回复
热议问题