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