NodeJS / Express: what is “app.use”?

后端 未结 23 1416
别跟我提以往
别跟我提以往 2020-11-29 14:48

In the docs for the NodeJS express module, the example code has app.use(...).

What is the use function and where is it defined?

23条回答
  •  醉话见心
    2020-11-29 15:24

    app.use() works like that:

    1. Request event trigered on node http server instance.
    2. express does some of its inner manipulation with req object.
    3. This is when express starts doing things you specified with app.use

    which very simple.

    And only then express will do the rest of the stuff like routing.

提交回复
热议问题