Differences between express.Router and app.get?

前端 未结 8 974
终归单人心
终归单人心 2020-11-29 14:24

I\'m starting with NodeJS and Express 4, and I\'m a bit confused. I been reading the Express website, but can\'t see when to use a route handler or when to use

相关标签:
8条回答
  • 2020-11-29 15:09

    express.Router has many options:

    • enable case sensitivity: /show route to not be the same as /Show, this behavior is disabled by default
    • strict routing mode: /show/ route to not the same as /show, this behavior is also disabled by default
    • we can add specific middleware/s to specific routes
    0 讨论(0)
  • 2020-11-29 15:13

    In a word , express.Routercan do more things when compares to app.get(),such as middleware, moreover, you can define one more router object with express.Router()

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