-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
38 lines (31 loc) · 973 Bytes
/
main.go
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
package main
import (
_ "github.com/jinzhu/gorm/dialects/mysql"
"github.com/mmirzaee/userist/models"
"github.com/mmirzaee/userist/rest"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
func init() {
initConfig()
models.Init()
}
func main() {
rest.Serve()
}
// initConfig reads in config file and ENV variables if set.
func initConfig() {
viper.AddConfigPath(".")
viper.SetConfigName("config")
viper.SetDefault("http_server", map[string]interface{}{"port": 4110, "host": "127.0.0.1"})
viper.SetDefault("jwt", map[string]interface{}{"secret": "DefaultUseristJWTsecRet!", "lifetime": 86400})
viper.SetDefault("log", map[string]interface{}{"enable_http_requests_log": false, "enable_mysql_queries_log": false})
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
log.WithFields(log.Fields{
"file": viper.ConfigFileUsed(),
}).Info("CONFIG: Loaded")
} else {
log.Fatal("CONFIG: File Not Found!")
}
}