Skip to content

Commit 91dda9f

Browse files
Moved to 204 no content
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
1 parent 2fb3719 commit 91dda9f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pkg/ffapi/apiserver.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,8 @@ func (as *apiServer[T]) notFoundHandler(res http.ResponseWriter, req *http.Reque
386386
return 404, i18n.NewError(req.Context(), i18n.Msg404NotFound)
387387
}
388388

389-
func (as *apiServer[T]) emptyJSONHandler(res http.ResponseWriter, _ *http.Request) (status int, err error) {
390-
res.Header().Add("Content-Type", "application/json")
391-
return 200, nil
389+
func (as *apiServer[T]) noContentResponder(res http.ResponseWriter, _ *http.Request) {
390+
res.WriteHeader(http.StatusNoContent)
392391
}
393392

394393
func (as *apiServer[T]) createMonitoringMuxRouter(ctx context.Context) (*mux.Router, error) {
@@ -400,7 +399,7 @@ func (as *apiServer[T]) createMonitoringMuxRouter(ctx context.Context) (*mux.Rou
400399
panic(err)
401400
}
402401
r.Path(as.metricsPath).Handler(h)
403-
r.HandleFunc(as.livenessPath, hf.APIWrapper(as.emptyJSONHandler))
402+
r.HandleFunc(as.livenessPath, as.noContentResponder)
404403

405404
for _, route := range as.MonitoringRoutes {
406405
path := route.Path

pkg/ffapi/apiserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func TestAPIServerInvokeAPIRouteLiveness(t *testing.T) {
232232

233233
res, err := resty.New().R().Get(fmt.Sprintf("%s/livez", as.MonitoringPublicURL()))
234234
assert.NoError(t, err)
235-
assert.Equal(t, 200, res.StatusCode()) // note this should really be 204, but not changing as would change behavior
235+
assert.Equal(t, 204, res.StatusCode())
236236
}
237237

238238
func TestAPIServerPanicsMisConfig(t *testing.T) {

0 commit comments

Comments
 (0)