mirror of
https://github.com/pikami/cosmium.git
synced 2025-03-12 21:05:29 +00:00
Configuration fixes
This commit is contained in:
parent
777034181f
commit
83f086a2dc
@ -16,6 +16,10 @@ import (
|
||||
func (s *ApiServer) CreateRouter(repository *repositories.DataRepository) {
|
||||
routeHandlers := handlers.NewHandlers(repository, s.config)
|
||||
|
||||
if !s.config.Debug {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
router := gin.Default(func(e *gin.Engine) {
|
||||
e.RedirectTrailingSlash = false
|
||||
})
|
||||
@ -61,10 +65,6 @@ func (s *ApiServer) CreateRouter(repository *repositories.DataRepository) {
|
||||
}
|
||||
|
||||
func (s *ApiServer) Start() {
|
||||
if !s.config.Debug {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
listenAddress := fmt.Sprintf(":%d", s.config.Port)
|
||||
s.isActive = true
|
||||
|
||||
|
@ -26,16 +26,19 @@ const (
|
||||
|
||||
//export CreateServerInstance
|
||||
func CreateServerInstance(serverName *C.char, configurationJSON *C.char) int {
|
||||
configStr := C.GoString(configurationJSON)
|
||||
serverNameStr := C.GoString(serverName)
|
||||
|
||||
if serverInstances == nil {
|
||||
serverInstances = make(map[string]*ServerInstance)
|
||||
}
|
||||
|
||||
if _, ok := serverInstances[C.GoString(serverName)]; ok {
|
||||
if _, ok := serverInstances[serverNameStr]; ok {
|
||||
return ResponseServerInstanceAlreadyExists
|
||||
}
|
||||
|
||||
var configuration config.ServerConfig
|
||||
err := json.Unmarshal([]byte(C.GoString(configurationJSON)), &configuration)
|
||||
err := json.Unmarshal([]byte(configStr), &configuration)
|
||||
if err != nil {
|
||||
return ResponseFailedToParseConfiguration
|
||||
}
|
||||
@ -50,7 +53,7 @@ func CreateServerInstance(serverName *C.char, configurationJSON *C.char) int {
|
||||
server := api.NewApiServer(repository, configuration)
|
||||
server.Start()
|
||||
|
||||
serverInstances[C.GoString(serverName)] = &ServerInstance{
|
||||
serverInstances[serverNameStr] = &ServerInstance{
|
||||
server: server,
|
||||
repository: repository,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user