From 5d6347e2faa5419bf5469858a2335aa9e2746c9a Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 14:55:39 +0530 Subject: feat(api): initialize HTTP API package --- internal/api/new.go | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 internal/api/new.go (limited to 'internal/api/new.go') diff --git a/internal/api/new.go b/internal/api/new.go new file mode 100644 index 0000000..3e949d3 --- /dev/null +++ b/internal/api/new.go @@ -0,0 +1,5 @@ +package api + +func New(config Config) *Server { + return &Server{} +} -- cgit v1.2.3 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/new.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'internal/api/new.go') diff --git a/internal/api/new.go b/internal/api/new.go index 3e949d3..d5f2b12 100644 --- a/internal/api/new.go +++ b/internal/api/new.go @@ -1,5 +1,17 @@ package api +import "net/http" + func New(config Config) *Server { - return &Server{} + mux := http.NewServeMux() + + server := &http.Server{ + Addr: config.Address, + Handler: mux, + } + + return &Server{ + config: config, + http: server, + } } -- cgit v1.2.3 From cbad596b7825550b2e9cb1d6322f50acd7f1c9a7 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 15:05:20 +0530 Subject: refactor(api): store HTTP multiplexer --- internal/api/new.go | 1 + 1 file changed, 1 insertion(+) (limited to 'internal/api/new.go') diff --git a/internal/api/new.go b/internal/api/new.go index d5f2b12..a9a08eb 100644 --- a/internal/api/new.go +++ b/internal/api/new.go @@ -12,6 +12,7 @@ func New(config Config) *Server { return &Server{ config: config, + mux: mux, http: server, } } -- cgit v1.2.3 From 735e7310c904abf18293456d37044dd9c5e796b0 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 15:12:51 +0530 Subject: feat(api): create a /health API endpoint --- internal/api/new.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'internal/api/new.go') diff --git a/internal/api/new.go b/internal/api/new.go index a9a08eb..d225b02 100644 --- a/internal/api/new.go +++ b/internal/api/new.go @@ -10,9 +10,16 @@ func New(config Config) *Server { Handler: mux, } - return &Server{ + srv := &Server{ config: config, mux: mux, http: server, } + + srv.mux.HandleFunc( + "GET /health", + srv.handleHealth, + ) + + return srv } -- cgit v1.2.3 From 0bf573c82118aaa5b60ab381dee26f43b10004b3 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 15:43:59 +0530 Subject: feat(api): wire application services --- internal/api/new.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'internal/api/new.go') diff --git a/internal/api/new.go b/internal/api/new.go index d225b02..4941496 100644 --- a/internal/api/new.go +++ b/internal/api/new.go @@ -11,9 +11,10 @@ func New(config Config) *Server { } srv := &Server{ - config: config, - mux: mux, - http: server, + config: config, + mux: mux, + http: server, + gallery: config.Gallery, } srv.mux.HandleFunc( -- cgit v1.2.3 From 56bb199787f8fc80b92779426644250f2709fd36 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 15:53:08 +0530 Subject: feat(api): expose gallery photos endpoint --- internal/api/new.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'internal/api/new.go') diff --git a/internal/api/new.go b/internal/api/new.go index 4941496..a7c122b 100644 --- a/internal/api/new.go +++ b/internal/api/new.go @@ -22,5 +22,10 @@ func New(config Config) *Server { srv.handleHealth, ) + srv.mux.HandleFunc( + "GET /api/photos", + srv.handlePhotos, + ) + return srv } -- cgit v1.2.3