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

4 years ago
  1. package conf
  2. import (
  3. "fmt"
  4. "github.com/kataras/iris/v12"
  5. )
  6. var ExampleFile = "http://localhost:8093/public/uploadxlsx/example.xlsx"
  7. var Baseurl = "http://localhost:8093"
  8. type AppConf struct {
  9. DisablePathCorrection bool
  10. EnablePathEscape bool
  11. FireMethodNotAllowed bool
  12. DisableBodyConsumptionOnUnmarshal bool
  13. TimeFormat string
  14. Charset string
  15. Other Other
  16. PublicRute []string
  17. }
  18. type Other struct {
  19. IgnoreURLs []string
  20. JWTTimeout int64
  21. LogLevel string
  22. Secret string
  23. }
  24. var AppConfig AppConf = AppConf{
  25. DisablePathCorrection: false,
  26. EnablePathEscape: false,
  27. FireMethodNotAllowed: false,
  28. DisableBodyConsumptionOnUnmarshal: false,
  29. TimeFormat: "Mon, 01 Jan 2006 15:04:05 GMT",
  30. Charset: "UTF-8",
  31. Other: Other{
  32. IgnoreURLs: []string{"/", "/user/login", "/user/plants","/admin/tabnames/download","/user/getimg"},//免token验证路径
  33. JWTTimeout: 72000,
  34. LogLevel: "debug",
  35. Secret: "lapp_gaas_gframe",
  36. },
  37. PublicRute: []string{"/sysMenu","/user/getuserinfo","/user/pwd","/user/avatar","/user/profile","/user/getimg","/admin/tabnames/list","/admin/stdeftab/selectarr","/admin/stdeftab/selectall"},//免权限检查路径
  38. }
  39. var (
  40. // conf strut
  41. C iris.Configuration
  42. // 解析app.yml中的Other项
  43. O Other
  44. // app.conf配置项key定义
  45. ignoreURLs string = "IgnoreURLs"
  46. jwtTimeout string = "JWTTimeout"
  47. logLevel string = "LogLevel"
  48. secret string = "Secret"
  49. )
  50. func AppOtherParse() {
  51. appData := AppConfig
  52. c := iris.DefaultConfiguration()
  53. c.DisableBodyConsumptionOnUnmarshal = appData.DisableBodyConsumptionOnUnmarshal
  54. c.DisablePathCorrection = appData.DisablePathCorrection
  55. c.EnablePathEscape = appData.EnablePathEscape
  56. c.FireMethodNotAllowed = appData.FireMethodNotAllowed
  57. c.TimeFormat = appData.TimeFormat
  58. c.Charset = appData.Charset
  59. other := make(map[string]interface{},0)
  60. other["IgnoreURLs"] = appData.Other.IgnoreURLs;
  61. other["JWTTimeout"] = appData.Other.JWTTimeout;
  62. other["LogLevel"] = appData.Other.LogLevel;
  63. other["Secret"] = appData.Other.Secret;
  64. c.Other = other
  65. C = c
  66. // 解析other的key
  67. iURLs := c.GetOther()[ignoreURLs].([]string)
  68. fmt.Println(iURLs)
  69. for _, v := range iURLs {
  70. O.IgnoreURLs = append(O.IgnoreURLs, v)
  71. }
  72. jTimeout := c.GetOther()[jwtTimeout].(int64)
  73. O.JWTTimeout = int64(jTimeout)
  74. //golog.Info(reflect.TypeOf(O.JWTTimeout))
  75. O.LogLevel = c.GetOther()[logLevel].(string)
  76. O.Secret = c.GetOther()[secret].(string)
  77. }