GAAS 广汽安道拓GFrame金属件MOM项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

90 lines
2.6 KiB

package conf
import (
"fmt"
"github.com/kataras/iris/v12"
)
var ExampleFile = "http://localhost:8093/public/uploadxlsx/example.xlsx"
var Baseurl = "http://localhost:8093"
type AppConf struct {
DisablePathCorrection bool
EnablePathEscape bool
FireMethodNotAllowed bool
DisableBodyConsumptionOnUnmarshal bool
TimeFormat string
Charset string
Other Other
PublicRute []string
}
type Other struct {
IgnoreURLs []string
JWTTimeout int64
LogLevel string
Secret string
}
var AppConfig AppConf = AppConf{
DisablePathCorrection: false,
EnablePathEscape: false,
FireMethodNotAllowed: false,
DisableBodyConsumptionOnUnmarshal: false,
TimeFormat: "Mon, 01 Jan 2006 15:04:05 GMT",
Charset: "UTF-8",
Other: Other{
IgnoreURLs: []string{"/", "/user/login", "/user/plants","/admin/tabnames/download","/user/getimg"},//免token验证路径
JWTTimeout: 72000,
LogLevel: "debug",
Secret: "lapp_gaas_gframe",
},
PublicRute: []string{"/sysMenu","/user/getuserinfo","/user/pwd","/user/avatar","/user/profile","/user/getimg","/admin/tabnames/list","/admin/stdeftab/selectarr","/admin/stdeftab/selectall"},//免权限检查路径
}
var (
// conf strut
C iris.Configuration
// 解析app.yml中的Other项
O Other
// app.conf配置项key定义
ignoreURLs string = "IgnoreURLs"
jwtTimeout string = "JWTTimeout"
logLevel string = "LogLevel"
secret string = "Secret"
)
func AppOtherParse() {
appData := AppConfig
c := iris.DefaultConfiguration()
c.DisableBodyConsumptionOnUnmarshal = appData.DisableBodyConsumptionOnUnmarshal
c.DisablePathCorrection = appData.DisablePathCorrection
c.EnablePathEscape = appData.EnablePathEscape
c.FireMethodNotAllowed = appData.FireMethodNotAllowed
c.TimeFormat = appData.TimeFormat
c.Charset = appData.Charset
other := make(map[string]interface{},0)
other["IgnoreURLs"] = appData.Other.IgnoreURLs;
other["JWTTimeout"] = appData.Other.JWTTimeout;
other["LogLevel"] = appData.Other.LogLevel;
other["Secret"] = appData.Other.Secret;
c.Other = other
C = c
// 解析other的key
iURLs := c.GetOther()[ignoreURLs].([]string)
fmt.Println(iURLs)
for _, v := range iURLs {
O.IgnoreURLs = append(O.IgnoreURLs, v)
}
jTimeout := c.GetOther()[jwtTimeout].(int64)
O.JWTTimeout = int64(jTimeout)
//golog.Info(reflect.TypeOf(O.JWTTimeout))
O.LogLevel = c.GetOther()[logLevel].(string)
O.Secret = c.GetOther()[secret].(string)
}