GoTomato/cmd/server/main.go
Sebastian Mark 09b475dd61 feat: create model for server config
- introduce GoTomatoServerConfig
- create instance variable with the current config
- update server to use configurable listen address and port

🤖
2024-10-20 14:45:13 +02:00

26 lines
584 B
Go

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.Printf("Pomodoro WebSocket server started on %s\n", listen)
err := http.ListenAndServe(listen, nil)
if err != nil {
log.Fatalf("Error starting server: %v", err)
}
}