aboutsummaryrefslogtreecommitdiff
path: root/internal/api/new.go
blob: a7c122bac00e4cb3c2dccf62b779131232df6cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
}