Revel 配置文件app.conf


本文整理自网络,侵删。

Revel 配置文件概述

app.conf 是Revel程序的配置文件,它使用 goconfig 语法,类似微软的 INI 文件。

下面是个例子:

app.name=chat
app.secret=pJLzyoiDe17L36mytqC912j81PfTiolHm1veQK6Grn1En3YFdB5lvEHVTwFEaWvj
http.addr=
http.port=9000

[dev]
results.pretty=true
watch=true

log.trace.output = off
log.info.output  = stderr
log.warn.output  = stderr
log.error.output = stderr

[prod]
results.pretty=false
watch=false

log.trace.output = off
log.info.output  = off
log.warn.output  = %(app.name)s.log
log.error.output = %(app.name)s.log

每个段是一种 运行模式。最上面的 key (不在任何段内)对所有的运行模式有效。这使得默认值在所有模式中适用,并且根据需要被重写。[prod] 段仅用于 生产 模式。

新建的Revel程序中默认定义了 dev 和 prod 模式, 你也可以自定义你需要的段。 程序启动时,根据 (命令行工具)“revel run” 提供的参数来选择运行模式。

自定义属性

开发者可以自定义key,并通过 revel.Config 变量 访问它们。这里公开了一些简单的 api。

内建属性

应用程序设置

app.name

应用程序名称,用于控制台输出和开发web页。

例如:

app.name = Booking example application

默认值: 无值


app.secret

密钥用于密码操作 (revel.Sign)。Revel 在内部使用它签署session cookies。设置为空将禁用签名。

使用 revel new新建项目时,它被设置为一个随机的字符串。

例如:

app.secret = pJLzyoiDe17L36mytqC912j81PfTiolHm1veQK6Grn1En3YFdB5lvEHVTwFEaWvj

默认值: 无值

HTTP settings

http.port

监听端口

例如:

http.port = 9000

http.addr

监听ip地址

Linux中, 空字符串代表通配符 – Windows中, 空字符串被转换为 "localhost"

默认值: ””


harness.port

Specifies the port for the application to listen on, when run by the harness. For example, when the harness is running, it will listen on http.port, run the application on harness.port, and reverse-proxy requests. Without the harness, the application listens on http.port directly.

默认情况下,会选择一个随??机的空闲端口。这仅仅是必要的,由该程序限制插座访问的环境中运行时设置。By default, a random free port will be chosen. This is only necessary to set when running in an environment that restricts socket access by the program.

Default: 0


http.ssl

如果为真, Revel Web服务器将自行配置为接受SSL连接。这需要一个 X509 证书和一个 key 文件。

默认值: false

http.sslcert

指定 X509 证书文件的路径

默认值: ””

http.sslkey

指定 X509 证书 key的路径

默认值: ””

响应结果

results.chunked

确定模板渲染时是否使用 分块编码。分块编码可以减少发送到客户端的第一个字节的时间(在整个模板已经完全呈现数据之前)。

默认值: false


results.pretty

配置 RenderXml 和 RenderJson 生成缩进格式的 XML/JSON. 例如:

results.pretty = true

默认值: false

国际化 (i18n)

i18n.default_language

为消息翻译指定默认??的语言,如果客户端请求的语言环境未确认。如果不指定,则返回一个虚拟的信息。

例如:

i18n.default_language = en

默认值: ””


i18n.cookie

指定存储用户语言环境的cookie名称

阅读剩余部分

相关阅读 >>

Revel 消息处理

Revel 命令行工具

Revel 模块概要

Revel 计划任务

Revel 过滤器

Revel 项目结构

Revel 部署

Revel 概念

Revel websockets

Revel 路由routes

更多相关阅读请进入《Revel》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...