aboutsummaryrefslogtreecommitdiff
path: root/internal/api/new.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/new.go')
-rw-r--r--internal/api/new.go31
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
+}