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 {
5252 httpapi .WriteBytes (rw , http .StatusOK , []byte ("Marketplace is running" ))
5353 })
5454
55+ r .Get ("/healthz" , func (rw http.ResponseWriter , r * http.Request ) {
56+ httpapi .WriteBytes (rw , http .StatusOK , []byte ("API server running" ))
57+ })
58+
5559 return & API {
5660 Handler : r ,
5761 }
Original file line number Diff line number Diff line change @@ -31,4 +31,8 @@ func TestServer(t *testing.T) {
3131 resp , err = http .Get (server .URL )
3232 require .NoError (t , err )
3333 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 )
3438}
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 {
2121
2222 next .ServeHTTP (sw , r )
2323
24+ // Do not log successful health check requests.
25+ if r .URL .Path == "/healthz" && sw .Status == 200 {
26+ return
27+ }
28+
2429 httplog = httplog .With (
2530 slog .F ("took" , time .Since (start )),
2631 slog .F ("status_code" , sw .Status ),
You can’t perform that action at this time.
0 commit comments