Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Add /ready endpoint for healthcheck #13

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions eventrecorder/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (r *EventRecorder) Start(ctx context.Context) error {
func (r *EventRecorder) httpServerMux() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("/v1/retrieval-events", r.handleRetrievalEvents)
mux.HandleFunc("/ready", r.handleReady)
return mux
}

Expand Down Expand Up @@ -149,6 +150,16 @@ func (r *EventRecorder) handleRetrievalEvents(res http.ResponseWriter, req *http
}
}

func (r *EventRecorder) handleReady(res http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodGet:
// TODO: ping DB as part of readiness check?
res.Header().Add("Allow", http.MethodGet)
default:
http.Error(res, "", http.StatusMethodNotAllowed)
}
}

func (r *EventRecorder) Shutdown(ctx context.Context) error {
return r.server.Shutdown(ctx)
}