Go Web开发之Revel - app.conf
2013-01-09 16:17
375 查看
应用程序配置文件被命名为app.conf,它使用goconfig的语法,它看起来有点像微软的INI文件。
下面是一个例子文件:
每一个section是一个运行模式.在文件最上面的Key(没有在任何section里面)被应用到全部的运行模式中,类似于全局变量。在[prod]下面的key只应用于prod模式。这允许默认值可以跨多种运行模式,当需要时也可以被重写。
新的应用程序以dev和prod运行模式运行,但用户也可以创建任意的section.运行模式的选择是在使用revel run时通过参数决定的。(命令行工具)
自定义属性
开发人员可以定义自己的key并通过
内建属性
Revel使用下面的内部属性:
app.name
app.secret - 密匙用于session cookie的签名 (and anywhere the application uses
http.port - 监听端口
http.addr - 绑定的ip地址(空字符串为通配符)
results.pretty -
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.* - 日志配置
至此结束。
下面是一个例子文件:
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.Configvariable来访问,它暴露了一个简单的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.* - 日志配置
至此结束。
相关文章推荐
- Go Web开发之Revel - 概念
- Go Web开发之Revel - 网页请求处理流程
- 【Go web开发之revel+mgo】第8章 实现Email墙
- Go Web开发之Revel - 测试
- Go Web开发之Revel - 模板
- 【Go web开发之revel+mgo】第2章 Blog的首页与投稿设计
- Go Web开发之Revel - Session/Flash
- 【Go web开发之revel+mgo】第4章 实现评论功能
- 【Go web开发之revel+mgo】第9章 其它和??
- Go Web开发之Revel - Getting Started
- Go Web开发之Revel - 参数绑定
- Go Web开发之Revel - 验证
- 【Go web开发之revel+mgo】第1章 述与环境
- Go Web开发之Revel - 命令行工具
- 【Go web开发之revel+mgo】第10章 总结
- Go Web开发之Revel - 组织结构
- Go Web开发之Revel - 拦截器
- 【Go web开发之revel+mgo】第3章 Blog的首页与投稿实现
- 【Go web开发之revel+mgo】第6章 实现留言板功能
- 【Go web开发之revel+mgo】第7章 实现归档