diff options
| author | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-07-13 17:39:59 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-13 17:39:59 +0530 |
| commit | ae29fa5ee155bb4828ea6eb8b164a30f7ec9fae8 (patch) | |
| tree | 4fbbce3d746c22a4cbb42ec53a9abd3e698bc67b /internal/api/new.go | |
| parent | cc639337ed5ccb4634b2a338f764cf9c73b02e4f (diff) | |
| parent | 56bb199787f8fc80b92779426644250f2709fd36 (diff) | |
| download | galleryd-ae29fa5ee155bb4828ea6eb8b164a30f7ec9fae8.tar.xz galleryd-ae29fa5ee155bb4828ea6eb8b164a30f7ec9fae8.zip | |
Merge pull request #6 from RanXom/feat/api
Feat/api: implement HTTP server and expose required endpoints
Diffstat (limited to 'internal/api/new.go')
| -rw-r--r-- | internal/api/new.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/api/new.go b/internal/api/new.go new file mode 100644 index 0000000..a7c122b --- /dev/null +++ b/internal/api/new.go @@ -0,0 +1,31 @@ +package api + +import "net/http" + +func New(config Config) *Server { + mux := http.NewServeMux() + + server := &http.Server{ + Addr: config.Address, + Handler: mux, + } + + srv := &Server{ + config: config, + mux: mux, + http: server, + gallery: config.Gallery, + } + + srv.mux.HandleFunc( + "GET /health", + srv.handleHealth, + ) + + srv.mux.HandleFunc( + "GET /api/photos", + srv.handlePhotos, + ) + + return srv +} |