Files
cloud-services/services/gateway/server/server_http.go
2026-01-31 01:51:04 -05:00

29 lines
904 B
Go

package server
import (
"context"
"net/http"
"github.com/fiskerinc/cloud-services/services/gateway/handlers"
"github.com/fiskerinc/cloud-services/pkg/httphandlers"
"github.com/fiskerinc/cloud-services/pkg/logger"
httptrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http"
)
// StartHTTP runs server for websockets and docs
func StartHTTP(ctx context.Context, port string) {
mux := httptrace.NewServeMux()
if docsHandler := handlers.DocsHandler(); docsHandler != nil {
mux.Handle("/docs/", http.StripPrefix("/docs", docsHandler))
}
mux.HandleFunc("/session", httphandlers.PanicHandler(handlers.SecureSessionWebsocketHandler))
mux.HandleFunc("/secret_mobile", httphandlers.PanicHandler(handlers.InsecureSessionWebsocketHandler))
logger.Info().Msgf("gateway websockets on http://0.0.0.0%s", port)
logger.Fatal().AnErr("http.ListenAndServe", http.ListenAndServe(port, mux)).Send()
}