MCPcopy Create free account
hub / github.com/cloudwan/gohan / getDatabaseConfig

Method getDatabaseConfig

server/server.go:175–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

173}
174
175func (server *Server) getDatabaseConfig() (string, string, db.InitDBParams) {
176 config := util.GetConfig()
177 databaseType := config.GetString("database/type", "sqlite3")
178 if databaseType == "json" || databaseType == "yaml" {
179 log.Fatal("json or yaml isn't supported as main db backend")
180 }
181 databaseConnection := config.GetString("database/connection", "")
182 if databaseConnection == "" {
183 log.Fatal("no database connection specified in the configuration file.")
184 }
185 databaseDropOnCreate := config.GetBool("database/drop_on_create", false)
186 databaseCascade := config.GetBool("database/cascade_delete", false)
187 databaseAutoMigrate := config.GetBool("database/auto_migrate", true)
188 return databaseType, databaseConnection, db.InitDBParams{
189 DropOnCreate: databaseDropOnCreate,
190 Cascade: databaseCascade,
191 AutoMigrate: databaseAutoMigrate,
192 AllowEmpty: false,
193 }
194}
195
196//NewServer returns new GohanAPIServer
197func NewServer(configFile string) (*Server, error) {

Callers 1

initDBMethod · 0.95

Calls 3

GetStringMethod · 0.80
FatalMethod · 0.80
GetBoolMethod · 0.80

Tested by

no test coverage detected