您的位置:首页 > 移动开发

Go Web开发之Revel - app.conf

2013-01-09 16:17 375 查看
应用程序配置文件被命名为app.conf,它使用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


每一个section是一个运行模式.在文件最上面的Key(没有在任何section里面)被应用到全部的运行模式中,类似于全局变量。在[prod]下面的key只应用于prod模式。这允许默认值可以跨多种运行模式,当需要时也可以被重写。

新的应用程序以dev和prod运行模式运行,但用户也可以创建任意的section.运行模式的选择是在使用revel run时通过参数决定的。(命令行工具

自定义属性

开发人员可以定义自己的key并通过
rev.Config
variable
来访问,它暴露了一个简单的api

内建属性

Revel使用下面的内部属性:

app.name

app.secret - 密匙用于session cookie的签名 (and anywhere the application uses
rev.Sign
)

http.port - 监听端口

http.addr - 绑定的ip地址(空字符串为通配符)

results.pretty -
RenderXml
RenderJson
格式化 XML/JSON.

watch - 允许源码监控. 如果设置为false将禁用监控(default true)

watch.templates - Revel应该监控和重新加载视图和模板文件的修改 (default True)

watch.routes - Revel应该监控和重新加载routes (default True)

watch.code - Revel应该监控和重新加载code (default True)

cookie.prefix - 重命名Revel的cookie名称 (default “REVEL”)

log.* - 日志配置

至此结束。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: