// Reads info from config file
Reads info from config file
// Reads info from config file
func NewConfig(file string) *UadminConfig {
	file = os.Getenv("UADMIN_PATH") + "/" + file
	_, err := os.Stat(file)
	if err != nil {
		log.Fatal("Config file is missing: ", file)
	}
	content, err := ioutil.ReadFile(file)
	if err != nil {
		log.Fatal(err)
	}
	c := UadminConfig{}
	err = yaml.Unmarshal([]byte(content), &c.D)
	if err != nil {
		log.Fatalf("error: %v", err)
	}
	c.ConfigContent = content
	c.PatternsToIgnoreCsrfCheck = list.New()
	c.PatternsToIgnoreCsrfCheck.PushBack("/ignorecsrfcheck/")
	c.RequiresCsrfCheck = func(c *gin.Context) bool {
		for e := CurrentConfig.PatternsToIgnoreCsrfCheck.Front(); e != nil; e = e.Next() {
			pathToIgnore := e.Value.(string)
			if c.Request.URL.Path == pathToIgnore {
				return false
			}
		}
		return true
	}
	CurrentConfig = &c
	return &c
}
func NewConfig ( file string ) * UadminConfig { file = os . Getenv ( " " ) + " " + file _ , err := os . Stat ( file ) if err != nil { log . Fatal ( " " , file ) } content , err := ioutil . ReadFile ( file ) if err != nil { log . Fatal ( err ) } c := UadminConfig { } err = yaml . Unmarshal ( [ ] byte ( content ) , & c . D ) if err != nil { log . Fatalf ( " " , err ) } c . ConfigContent = content c . PatternsToIgnoreCsrfCheck = list . New ( ) c . PatternsToIgnoreCsrfCheck . PushBack ( " " ) c . RequiresCsrfCheck = func ( c * gin . Context ) bool { for e := CurrentConfig . PatternsToIgnoreCsrfCheck . Front ( ) ; e != nil ; e = e . Next ( ) { pathToIgnore := e . Value . ( string ) if c . Request . URL . Path == pathToIgnore { return false } } return true } CurrentConfig = & c return & c }
Reads info from config file
Reads info from config file