diff --git a/cmd/server/main.go b/cmd/server/main.go index 6470e4d..3d1c9f8 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -1,16 +1,25 @@ package server import ( + "fmt" "git.smsvc.net/pomodoro/GoTomato/internal/websocket" + "git.smsvc.net/pomodoro/GoTomato/pkg/models" "log" "net/http" ) +var serverConfig = models.GoTomatoServerConfig{ + ListenAddress: "0.0.0.0", + ListenPort: 8080, +} + func Start() { + listen := fmt.Sprintf("%s:%d", serverConfig.ListenAddress, serverConfig.ListenPort) + http.HandleFunc("/ws", websocket.HandleConnections) - log.Println("Pomodoro WebSocket server started on :8080") - err := http.ListenAndServe(":8080", nil) + log.Printf("Pomodoro WebSocket server started on %s\n", listen) + err := http.ListenAndServe(listen, nil) if err != nil { log.Fatalf("Error starting server: %v", err) } diff --git a/pkg/models/config.go b/pkg/models/config.go new file mode 100644 index 0000000..59db277 --- /dev/null +++ b/pkg/models/config.go @@ -0,0 +1,6 @@ +package models + +type GoTomatoServerConfig struct { + ListenAddress string `json:"listenAddress"` + ListenPort int `json:"listenPort"` +}