add models and jwt
This commit is contained in:
22
conf/conf.ini
Normal file
22
conf/conf.ini
Normal file
@@ -0,0 +1,22 @@
|
||||
[mysql]
|
||||
Type = mysql
|
||||
Host = 127.0.0.1
|
||||
Port = 3306
|
||||
User = root
|
||||
Password = root
|
||||
DB = login
|
||||
Charset = utf8mb4
|
||||
;Prefix = gin_
|
||||
|
||||
[jwt]
|
||||
SecretKey = \x13\xbf\xd2 1\xce\x8b\xc1\t\xc1=\xec\x07\x93\xd4\x9e\xbco\xb0Z
|
||||
|
||||
[project]
|
||||
StaticUrlMapPath = {"assets/static/": "static/", "assets/docs/": "docs/", "media/": "media/"}
|
||||
TemplateGlob = templates/**/*
|
||||
MediaFilePath = "media/upload/"
|
||||
|
||||
[server]
|
||||
Port = 7890
|
||||
ReadTimeout = 60
|
||||
WriteTimeout = 60
|
||||
65
conf/config.go
Normal file
65
conf/config.go
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
@Time : 2020/6/28 21:48
|
||||
@Author : xuyiqing
|
||||
@File : config.py
|
||||
*/
|
||||
|
||||
package conf
|
||||
|
||||
import (
|
||||
"github.com/go-ini/ini"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SqlDataBase struct {
|
||||
Type string
|
||||
Host string
|
||||
Port string
|
||||
User string
|
||||
Password string
|
||||
DB string
|
||||
Charset string
|
||||
Prefix string
|
||||
}
|
||||
|
||||
type Jwt struct {
|
||||
SecretKey string
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
StaticUrlMapPath string
|
||||
TemplateGlob string
|
||||
MediaFilePath string
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
Port string
|
||||
ReadTimeout time.Duration
|
||||
WriteTimeout time.Duration
|
||||
}
|
||||
|
||||
var (
|
||||
DataBase = &SqlDataBase{}
|
||||
JwtSecretKey = &Jwt{}
|
||||
ProjectCfg = &Project{}
|
||||
HttpServer = &Server{}
|
||||
)
|
||||
|
||||
func SetUp() {
|
||||
cfg, err := ini.Load("conf/conf.ini")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cfg.Section("mysql").MapTo(DataBase); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cfg.Section("jwt").MapTo(JwtSecretKey); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cfg.Section("project").MapTo(ProjectCfg); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cfg.Section("server").MapTo(HttpServer); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user