Revel 配置文件app.conf
本文整理自网络,侵删。
Revel 配置文件概述
app.conf 是Revel程序的配置文件,它使用 goconfig 语法,类似微软的 INI 文件。
下面是个例子:
app.name=chatapp.secret=pJLzyoiDe17L36mytqC912j81PfTiolHm1veQK6Grn1En3YFdB5lvEHVTwFEaWvjhttp.addr=http.port=9000[dev]results.pretty=truewatch=truelog.trace.output = offlog.info.output = stderrlog.warn.output = stderrlog.error.output = stderr[prod]results.pretty=falsewatch=falselog.trace.output = offlog.info.output = offlog.warn.output = %(app.name)s.loglog.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 = 9000http.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 results
Revel 参数绑定
Revel 控制器概要
Revel 日志类型
Revel websockets
Revel 版本控制
Revel 测试
Revel 介绍
Revel 控制器
Revel 概念
更多相关阅读请进入《Revel》频道 >>
Go语言101
一个与时俱进的Go编程知识库。
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
