~fmac/pasticcio

ref: dcd4deae5f567c3074b6f309955c4e6a4f72123a pasticcio/config/default.go -rw-r--r-- 911 bytes
dcd4deae — Francesco Camuffo Config: include info URLs 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package config

import (
	"github.com/spf13/viper"
)

type Config struct {
	AppTitle      string `mapstructure:"appTitle"`
	GinMode       string `mapstructure:"ginMode"`
	Address       string `mapstructure:"address"`
	Port          string `mapstructure:"port"`
	TemplatesPath string `mapstructure:"templatesPath"`
	WebRootPath   string `mapstructure:"webRootPath"`

	Db Db `mapstructure:"db"`

	Info Info `mapstructure:"info"`
}

type Db struct {
	Driver string `mapstructure:"driver"`
	Url    string `mapstructure:"url"`
}

type Info struct {
	PrivacyUrl string `mapstructure:"privacyUrl"`
	SrcUrl     string `mapstructure:"srcUrl"`
}

func LoadConfig() (config Config, err error) {
	viper.SetConfigName("config")
	viper.SetConfigType("yaml")
	viper.AddConfigPath("/etc/pasticcio/")
	viper.AddConfigPath(".")

	err = viper.ReadInConfig()
	if err != nil {
		return
	}

	err = viper.Unmarshal(&config)
	return
}