国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

翻譯---express 4.x版本官網的app.set()的屬性和使用方法

2019-11-08 02:39:53
字體:
來源:轉載
供稿:網友

app.set(name, value)

Assigns setting name to value, where name is one of the PRoperties from theapp settings table.

分配  設定  名字 給 值,這里的名字是一個 app 設定表 的屬性

Calling app.set('foo', true) for a Boolean property is the same as callingapp.enable('foo'). Similarly, calling app.set('foo', false) for a Boolean property

把 app.set('foo', true) 作為 一個 布爾類型 屬性 是 和 app.enable('foo')一樣的。 相似地, 把app.set('foo', false)作為 一個布爾類型屬性

is the same as calling app.disable('foo').

是和 app.disable('foo')一樣的。

Retrieve the value of a setting with app.get().

檢索 設置 的值 用 app.get().

app.set('title', 'My Site');app.get('title'); // "My Site"

application Settings

應用 設定

If name is one of the application settings, it affects the behavior of the application. The following table lists application settings.

如果 名字 是 一個 應用程序 設置, 它 會影響 應用程序 的 行為方式。 下表 列出 應用程序 設置

PropertyTypeValueDefault

case sensitive routing

區分大小寫

路由選擇

Boolean

Enable case sensitivity.

啟用區分大小寫

Disabled. Treats "/Foo" and "/foo" as the same.

不啟用。把"/Foo" and "/foo" 看作是一樣的

env

外部命令

String

Environment mode.

列出所有環境變量及其賦值

process.env.NODE_ENV (NODE_ENV environment variable) or “development”.

etag

被請求變量的實體值,實體標簽

Varied

Set the ETag response header. For possible values, see the etag options table.

設置 ETag 請求的 報頭。對于 可能的 值,看 etag options table

More about the HTTP ETag header.

 

jsonp callback name

jsonp 回調名字

String

Specifies the default JSONP callback name.

指定 默認 jsonp 回調 名字(開啟透明的 jsonp支持)

?callback=

json replacer

json 替代者

String

JSON replacer callback.

JSON 替代者 回調

null

json spaces

json 空間

Number

When set, sends prettified JSON string indented with the specified amount of spaces.

當 設置好 的時候, 發送 修飾好了的 和 打算的 指定大小的空間 json 字符串

Disabled.

不啟用

query parser

查詢解析器

String

The query parser to use, either “simple” or “extended”. The simple query parser is based on Node’s

查詢解析器使用,要么 簡單 要么 拓展。 這個簡單 的 查詢解析器 是基于 node 的 本地查詢解析器,

native query parser, querystring. The extended query parser is based on qs.

querystring. 這個 拓展的 查詢解析器 是基于 qs.querystring.

"extended"

strict routing

嚴格的路由選擇

(嚴格路徑)

Boolean

Enable strict routing.

啟用 嚴格 的路由 選擇(啟用后不會忽略路徑末尾的 '/')

Disabled. Treats "/foo" and "/foo/" as the

不啟用。把"/Foo" and "/foo" 看作是一樣的

same by the router.

subdomain

offset

子域名偏移量

Number

The number of dot-separated parts of the host to remove to access subdomain.

許多用點號 分隔的 主機部分被移除 為了訪問 子域

2

trust proxy

信任代理

Varied

Indicates the app is behind a front-facing proxy, and to use the X-Forwarded-* headers to determine the connection and the ip address of the client. NOTE: X-Forwarded-* headers are easily spoofed and the detected IP addresses are unreliable.

trust proxy is disabled by default. When enabled, Express attempts to determine the IP address of the client connected through the front-facing proxy, or series of proxies. The req.ips property, then, contains an array of IP addresses the client is connected through. To enable it, use the values described in the trust proxy options table.

The trust proxy setting is implemented using the proxy-addr package. For more information, see its documentation.

指示應用程序是一個前置代理的背后,并用x-forwarded *頭來確定連接和客戶端的IP地址。注:x-forwarded *頭很容易偽造并且檢測到的IP地址是不可靠的。

zhǐshìyìngyòngchéngshìqiánzhìdàidebèihòu, bìngyòngx - f o r w a r d e d * tóuláiquèdìngliánjiēduāndeI P zhǐ。 zhùx - f o r w a r d e d * tóuhěnróngwěizàojiǎndàodeI P zhǐshìkàode。

trust proxy is disabled by default. When enabled, Express attempts to determine the IP address of the client connected through the front-facing proxy, or series of proxies. The req.ips property, then, contains an array of IP addresses the client is connected through. To enable it, use the values described in the trust proxy options table.

默認情況下信任代理已禁用。啟用時,表示試圖通過前面的代理或一系列代理連接來確定客戶端的IP地址的req.ips財產,然后,包含IP地址的客戶端連接到陣列。要啟用它,請使用“信任代理選項表”中描述的值。

rènqíngkuàngxiàxìnrèndàijìnyòng。 yòngshíbiǎoshìshìtōngguòqiánmiàndàihuòlièdàiliánjiēláiquèdìngduāndeI P zhǐder e q . i p s cáichǎn, ránhòu, bāohánI P zhǐdeduānliánjiēdàozhènlièyàoyòngqǐngshǐ使 yòngxìnrèndàixuǎnxiàngbiǎozhōngmiáoshùdezhí。

The trust proxy setting is implemented using the proxy-addr package. For more information, see its documentation.

信托代理設置使用代理地址封裝實現。有關更多信息,請參見其文檔。

Disabled.

views

視圖

String or Array

A directory or an array of directories for the application's views.

應用程序視圖的一個目錄或者一組目錄(用于存放模板文件)

If an array, the views are looked up in the order they occur in the array.

如果是一個數組,這個視圖 是 按出現在數組里的順序 查詢 的

process.cwd() + '/views'

view cache

視圖緩存

Boolean

Enables view template compilation caching.

啟用 視圖 模板 編譯 緩存

true in production.

在生產中true

view engine

視圖模板引擎

String

The default engine extension to use when omitted.

當省略了的時候 默認的拓展引擎會被使用

 

x-powered-by

x驅動

Boolean

Enables the "X-Powered-By: Express" HTTP header.

啟用"X-Powered-By,Express" HTTP 報頭

true

Options for `trust proxy` setting
TypeValue
Boolean

If true, the client’s IP address is understood as the left-most entry in the X-Forwarded-* header.

If false, the app is understood as directly facing the Internet and the client’s IP address is derived from req.connection.remoteAddress. This is the default setting.

IP addresses

An IP address, subnet, or an array of IP addresses, and subnets to trust. The following is the list of pre-configured subnet names.

loopback - 127.0.0.1/8, ::1/128linklocal - 169.254.0.0/16, fe80::/10uniquelocal - 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7

Set IP addresses in any of the following ways:

app.set('trust proxy', 'loopback') // specify a single subnet app.set('trust proxy', 'loopback, 123.123.123.123') // specify a subnet and an address app.set('trust proxy', 'loopback, linklocal, uniquelocal') // specify multiple subnets as CSV app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']) // specify multiple subnets as an array

When specified, the IP addresses or the subnets are excluded from the address determination process, and the untrusted IP address nearest to the application server is determined as the client’s IP address.

Number

Trust the nth hop from the front-facing proxy server as the client.

Function

Custom trust implementation. Use this only if you know what you are doing.

app.set('trust proxy', function (ip) { if (ip === '127.0.0.1' || ip === '123.123.123.123') return true; // trusted IPs else return false; })
Options for `etag` setting
TypeValue
Boolean

true enables weak ETag. This is the default setting.false disables ETag altogether.

StringIf "strong", enables strong ETag.If "weak", enables weak ETag.
Function

Custom ETag function implementation. Use this only if you know what you are doing.

app.set('etag', function (body, encoding) { return generateHash(body, encoding); // consider the function is defined })
http://www.expressjs.com.cn/4x/api.html#app.set (English版本)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西畴县| 通山县| 铜陵市| 江安县| 革吉县| 洛隆县| 夏邑县| 陆川县| 石河子市| 浑源县| 隆昌县| 永康市| 黑水县| 攀枝花市| 鹿泉市| 伊川县| 西藏| 靖江市| 谷城县| 西平县| 台前县| 龙门县| 邹城市| 临颍县| 鹰潭市| 抚松县| 沧源| 德钦县| 崇礼县| 精河县| 亚东县| 汨罗市| 浪卡子县| 武强县| 湖南省| 南皮县| 阜平县| 涟水县| 长沙市| 白城市| 奈曼旗|