-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouts.go
40 lines (35 loc) · 1.09 KB
/
routs.go
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
32
33
34
35
36
37
38
39
40
package router
import (
"net/http"
)
type endpoints struct {
health []endpoint
private []endpoint
public []endpoint
}
type endpoint struct {
path string
methods []method
}
type method struct {
verb string
handler func(w http.ResponseWriter, r *http.Request)
}
// ep returns all the endpoints and their config. This is where all endpoints are configured
// TODO: Add your endpoints
func ep(h IHandler) endpoints {
return endpoints{
health: []endpoint{
{path: "/", methods: []method{{verb: http.MethodGet, handler: h.OK}}},
{path: "/healthz", methods: []method{{verb: http.MethodGet, handler: h.Healthz}}},
{path: "/readz", methods: []method{{verb: http.MethodGet, handler: h.Readyz}}},
{path: "/livez", methods: []method{{verb: http.MethodGet, handler: h.Livez}}},
},
private: []endpoint{
{path: "/hello", methods: []method{{verb: http.MethodGet, handler: h.Hello}, {verb: http.MethodOptions, handler: h.OK}}},
},
public: []endpoint{
{path: "/hello", methods: []method{{verb: http.MethodGet, handler: h.Hello}, {verb: http.MethodOptions, handler: h.OK}}},
},
}
}