码迷,mamicode.com
首页 > 移动开发 > 详细

app.use

时间:2016-02-26 11:52:15      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

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.

 

app.use

标签:

原文地址:http://www.cnblogs.com/tekkaman/p/5219616.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!