add service b

This commit is contained in:
2025-10-30 11:40:41 +01:00
parent 90020de1ec
commit e0929aff56
8 changed files with 203 additions and 7 deletions
+21 -7
View File
@@ -2,17 +2,31 @@ package main
import (
"fmt"
"log"
"log/slog"
"net/http"
"serviceb/internal/domains/meteo"
"serviceb/internal/router"
"time"
)
func main() {
mux := http.NewServeMux()
mux := router.SetupRoutes()
mux.HandleFunc("GET /hello", func(w http.ResponseWriter, r *http.Request) {
log.Println("Received request on /hello endpoint")
fmt.Fprintf(w, "Hello world from service B")
})
meteoService := meteo.NewService()
meteoHandler := meteo.NewHandler(meteoService)
meteo.RegisterRoutes(mux, meteoHandler)
http.ListenAndServe(":8090", mux)
server := http.Server{
Addr: ":8090",
Handler: mux,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
IdleTimeout: 60 * time.Second,
ReadHeaderTimeout: 5 * time.Second,
}
slog.Info("server starting on :8090")
if err := server.ListenAndServe(); err != nil {
panic(fmt.Sprintf("server failed, error %s", err))
}
}