package api import ( "context" "encoding/json" "net/http" "time" ) type Server struct { httpServer *http.Server } func NewServer(addr string, readTimeout, writeTimeout time.Duration) *Server { mux := http.NewServeMux() mux.HandleFunc("/health", healthHandler) return &Server{ httpServer: &http.Server{ Addr: addr, Handler: mux, ReadTimeout: readTimeout, WriteTimeout: writeTimeout, }, } } func (s *Server) Start() error { return s.httpServer.ListenAndServe() } func (s *Server) Shutdown(ctx context.Context) error { return s.httpServer.Shutdown(ctx) } func healthHandler(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) _ = json.NewEncoder(w).Encode(map[string]string{"status": "ok"}) }