File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ func New(options *Options) *API {
52
52
httpapi .WriteBytes (rw , http .StatusOK , []byte ("Marketplace is running" ))
53
53
})
54
54
55
+ r .Get ("/healthz" , func (rw http.ResponseWriter , r * http.Request ) {
56
+ httpapi .WriteBytes (rw , http .StatusOK , []byte ("API server running" ))
57
+ })
58
+
55
59
return & API {
56
60
Handler : r ,
57
61
}
Original file line number Diff line number Diff line change @@ -31,4 +31,8 @@ func TestServer(t *testing.T) {
31
31
resp , err = http .Get (server .URL )
32
32
require .NoError (t , err )
33
33
require .Equal (t , http .StatusOK , resp .StatusCode )
34
+
35
+ resp , err = http .Get (server .URL + "/healthz" )
36
+ require .NoError (t , err )
37
+ require .Equal (t , http .StatusOK , resp .StatusCode )
34
38
}
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ func Logger(log slog.Logger) func(next http.Handler) http.Handler {
21
21
22
22
next .ServeHTTP (sw , r )
23
23
24
+ // Do not log successful health check requests.
25
+ if r .URL .Path == "/healthz" && sw .Status == 200 {
26
+ return
27
+ }
28
+
24
29
httplog = httplog .With (
25
30
slog .F ("took" , time .Since (start )),
26
31
slog .F ("status_code" , sw .Status ),
You can’t perform that action at this time.
0 commit comments