knowyt/server/src/application/getServerInfo.go
Settel a243deb79e
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
init game when database is empty
bind server to interface given by CLI option
2023-01-29 15:06:46 +01:00

21 lines
395 B
Go

package application
import (
"encoding/json"
"fmt"
"net/http"
)
func (app *Application) GetServerInfo(w http.ResponseWriter, r *http.Request) {
app.mu.Lock()
defer app.mu.Unlock()
serverInfo := ServerInfo{
IsInitialized: len(app.users) > 1,
}
w.Header().Add("Content-Type", "application/json")
jsonString, _ := json.Marshal(serverInfo)
fmt.Fprintf(w, "%s", string(jsonString))
}