mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
add option to enable api server
This commit is contained in:
7
api.go
7
api.go
@@ -15,6 +15,10 @@ import (
|
||||
)
|
||||
|
||||
func (r *Router) startAPIServer(config config.ApiConfig) {
|
||||
if !config.Enabled {
|
||||
r.logger.Warn("API not enabled")
|
||||
return
|
||||
}
|
||||
r.logger.Debug("starting API server", "port", config.Port)
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/ws", r.handleWebsocket)
|
||||
@@ -36,6 +40,9 @@ func (r *Router) startAPIServer(config config.ApiConfig) {
|
||||
}
|
||||
|
||||
func (r *Router) stopAPIServer() {
|
||||
if r.apiServer == nil {
|
||||
return
|
||||
}
|
||||
r.logger.Debug("stopping API server")
|
||||
r.apiServerMu.Lock()
|
||||
defer r.apiServerMu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user