Sebastian Mark
09b475dd61
- introduce GoTomatoServerConfig
- create instance variable with the current config
- update server to use configurable listen address and port
🤖
26 lines
584 B
Go
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)
|
|
}
|
|
}
|