From cee3fcb2be34f86bdd6a3e19cb57a2e3c1cf34b4 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 15:02:39 +0530 Subject: feat(api): implement HTTP server --- internal/api/run.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 internal/api/run.go (limited to 'internal/api/run.go') diff --git a/internal/api/run.go b/internal/api/run.go new file mode 100644 index 0000000..0bd8a9b --- /dev/null +++ b/internal/api/run.go @@ -0,0 +1,24 @@ +package api + +import ( + "context" + "errors" + "net/http" +) + +// Run starts the HTTP server and blocks until it exits. +func (s *Server) Run(ctx context.Context) error { + go func() { + <-ctx.Done() + + _ = s.http.Shutdown(context.Background()) + }() + + err := s.http.ListenAndServe() + + if errors.Is(err, http.ErrServerClosed) { + return nil + } + + return err +} -- cgit v1.2.3