mirror of
https://github.com/cuigh/swirl
synced 2025-03-03 18:51:34 +00:00
Switch config to YAML format
This is a breaking change if you used file config.
This commit is contained in:
parent
ac5184037a
commit
59c8d6cf36
2
config/app.prd.yml
Normal file
2
config/app.prd.yml
Normal file
@ -0,0 +1,2 @@
|
||||
swirl:
|
||||
docker_endpoint: tcp://docker-proxy:2375
|
@ -1,14 +0,0 @@
|
||||
<config>
|
||||
<app>
|
||||
<add key="name" value="swirl"/>
|
||||
<add key="debug" value="true"/>
|
||||
</app>
|
||||
<web>
|
||||
<add key="address" value=":8001"/>
|
||||
<add key="authorize_mode" value="?"/>
|
||||
</web>
|
||||
<!-- <swirl>
|
||||
<add key="db_type" value="mongo"/>
|
||||
<add key="db_address" value="localhost:27017/swirl"/>
|
||||
</swirl> -->
|
||||
</config>
|
20
config/app.yml
Normal file
20
config/app.yml
Normal file
@ -0,0 +1,20 @@
|
||||
name: swirl
|
||||
|
||||
web:
|
||||
address: ':8001'
|
||||
authorize_mode: '*'
|
||||
|
||||
swirl:
|
||||
db_type: mongo
|
||||
db_address: localhost:27017/swirl
|
||||
# docker_endpoint: tcp://docker-proxy:2375
|
||||
|
||||
#log:
|
||||
# loggers:
|
||||
# - level: info
|
||||
# writers: console
|
||||
# writers:
|
||||
# - name: console
|
||||
# type: console
|
||||
# format: json
|
||||
# layout: '[{L}]{T}: {M} - {F:S}{N}'
|
@ -1,8 +0,0 @@
|
||||
<profiles>
|
||||
<profile>
|
||||
<option key="debug" value="false"/>
|
||||
</profile>
|
||||
<profile name="dev">
|
||||
<option key="debug" value="true"/>
|
||||
</profile>
|
||||
</profiles>
|
2
main.go
2
main.go
@ -35,7 +35,7 @@ func main() {
|
||||
ws := web.Auto()
|
||||
|
||||
// set render/validator..
|
||||
ws.Renderer = jet.New().SetDebug(config.App().Debug).
|
||||
ws.Renderer = jet.New().SetDebug(config.GetBool("debug")).
|
||||
AddFunc("time", misc.FormatTime(setting.TimeZone.Offset)).
|
||||
AddFunc("i18n", misc.Message(setting.Language)).
|
||||
AddFuncs(misc.Funcs).
|
||||
|
16
misc/misc.go
16
misc/misc.go
@ -4,12 +4,11 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/cuigh/auxo/config"
|
||||
"github.com/cuigh/auxo/data"
|
||||
)
|
||||
|
||||
const (
|
||||
// Version is the version of Swirl
|
||||
Version = "0.5.6"
|
||||
Version = "0.6"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -25,16 +24,13 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
options := config.App().GetSection("swirl")
|
||||
DockerHost = loadOption(options, "docker_endpoint", envDockerEndpoint)
|
||||
DBType = loadOption(options, "db_type", envDBType)
|
||||
DBAddress = loadOption(options, "db_address", envDBAddress)
|
||||
DockerHost = loadOption("swirl.docker_endpoint", envDockerEndpoint)
|
||||
DBType = loadOption("swirl.db_type", envDBType)
|
||||
DBAddress = loadOption("swirl.db_address", envDBAddress)
|
||||
}
|
||||
|
||||
func loadOption(options data.Options, key, env string) (opt string) {
|
||||
if options != nil {
|
||||
opt = options.String(key)
|
||||
}
|
||||
func loadOption(key, env string) (opt string) {
|
||||
opt = config.GetString(key)
|
||||
if opt == "" {
|
||||
opt = os.Getenv(env)
|
||||
}
|
||||
|
@ -51,6 +51,9 @@ func Message(lang string) func(key string, args ...interface{}) string {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if t == nil {
|
||||
panic("can't find language files")
|
||||
}
|
||||
|
||||
return func(key string, args ...interface{}) string {
|
||||
if s := t.Format(key, args...); s != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user