mirror of
https://github.com/cuigh/swirl
synced 2025-03-04 02:57:12 +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()
|
ws := web.Auto()
|
||||||
|
|
||||||
// set render/validator..
|
// 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("time", misc.FormatTime(setting.TimeZone.Offset)).
|
||||||
AddFunc("i18n", misc.Message(setting.Language)).
|
AddFunc("i18n", misc.Message(setting.Language)).
|
||||||
AddFuncs(misc.Funcs).
|
AddFuncs(misc.Funcs).
|
||||||
|
16
misc/misc.go
16
misc/misc.go
@ -4,12 +4,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cuigh/auxo/config"
|
"github.com/cuigh/auxo/config"
|
||||||
"github.com/cuigh/auxo/data"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Version is the version of Swirl
|
// Version is the version of Swirl
|
||||||
Version = "0.5.6"
|
Version = "0.6"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -25,16 +24,13 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
options := config.App().GetSection("swirl")
|
DockerHost = loadOption("swirl.docker_endpoint", envDockerEndpoint)
|
||||||
DockerHost = loadOption(options, "docker_endpoint", envDockerEndpoint)
|
DBType = loadOption("swirl.db_type", envDBType)
|
||||||
DBType = loadOption(options, "db_type", envDBType)
|
DBAddress = loadOption("swirl.db_address", envDBAddress)
|
||||||
DBAddress = loadOption(options, "db_address", envDBAddress)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadOption(options data.Options, key, env string) (opt string) {
|
func loadOption(key, env string) (opt string) {
|
||||||
if options != nil {
|
opt = config.GetString(key)
|
||||||
opt = options.String(key)
|
|
||||||
}
|
|
||||||
if opt == "" {
|
if opt == "" {
|
||||||
opt = os.Getenv(env)
|
opt = os.Getenv(env)
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,9 @@ func Message(lang string) func(key string, args ...interface{}) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if t == nil {
|
||||||
|
panic("can't find language files")
|
||||||
|
}
|
||||||
|
|
||||||
return func(key string, args ...interface{}) string {
|
return func(key string, args ...interface{}) string {
|
||||||
if s := t.Format(key, args...); s != "" {
|
if s := t.Format(key, args...); s != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user