MCPcopy Create free account
hub / github.com/apache/casbin-server / LoadConfiguration

Function LoadConfiguration

server/adapter.go:133–150  ·  view source on GitHub ↗
(file string)

Source from the content-addressed store, hash-verified

131}
132
133func LoadConfiguration(file string) Config {
134 //Loads a default config from adapter_config in case a custom adapter isn't provided by the client.
135 //DriverName, ConnectionString, and dbSpecified can be configured in the file. Defaults to 'file' mode.
136
137 configFile, err := os.Open(file)
138 if err != nil {
139 fmt.Println(err.Error())
140 }
141 decoder := json.NewDecoder(configFile)
142 config := Config{}
143 decoder.Decode(&config)
144 re := regexp.MustCompile(`\$\b((\w*))\b`)
145 config.Connection = re.ReplaceAllStringFunc(config.Connection, func(s string) string {
146 return os.Getenv(strings.TrimPrefix(s, `$`))
147 })
148
149 return config
150}
151
152type Config struct {
153 Driver string

Callers 2

checkLocalConfigFunction · 0.85
NewEnforcerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected