diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-07-13 15:02:39 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-07-13 15:02:39 +0530 |
| commit | cee3fcb2be34f86bdd6a3e19cb57a2e3c1cf34b4 (patch) | |
| tree | 5e4b11e55ffe4e0a47860000b2ae6d655b42cb69 /internal/api/run.go | |
| parent | 5d6347e2faa5419bf5469858a2335aa9e2746c9a (diff) | |
| download | galleryd-cee3fcb2be34f86bdd6a3e19cb57a2e3c1cf34b4.tar.xz galleryd-cee3fcb2be34f86bdd6a3e19cb57a2e3c1cf34b4.zip | |
feat(api): implement HTTP server
Diffstat (limited to 'internal/api/run.go')
| -rw-r--r-- | internal/api/run.go | 24 |
1 files changed, 24 insertions, 0 deletions
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 +} |