Tekkaman

导航

 

app.use

  Mounts the middleware function(s) at the path. If path is not specified, it defaults to “/”.

  A route will match any path, which follows its path immediately with a “/”. For example: app.use('/apple', ...) will match “/apple”, “/apple/images”, “/apple/images/news”, and so on.

  req.originalUrl in a middleware is a combination of req.baseUrl and req.path, as shown in the following example.

  

  

  Middleware functions are executed sequentially, therefore the order of middleware inclusion is important.

  

  路径可以是 path、path pattern、regular expression.

  Disable logging for static content requests by loading the logger middleware after the static middleware:

  

参考:http://www.expressjs.com.cn/4x/api.html#app.use

__dirname

  nodejs中的全局变量。

  The name of the directory that the currently executing script resides in.

 

  Example: running node example.js from /Users/mjr

  

  __dirname isn't actually a global but rather local to each module.

 

posted on 2016-02-26 10:44  Tekkaman  阅读(291)  评论(1编辑  收藏  举报