Skip to content

Commit

Permalink
Add health route (#2)
Browse files Browse the repository at this point in the history
* Add health route

* fix readme test
  • Loading branch information
ostcar committed Jul 22, 2021
1 parent 0e01674 commit e38eac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/icchttp/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,14 @@ func AuthMiddleware(next http.Handler, auth Authenticater) http.Handler {
next.ServeHTTP(w, r)
})
}

// HandleHealth returns 200 (if the service is running).
func HandleHealth(mux *http.ServeMux) {
mux.HandleFunc(
"/system/icc/health",
func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/octet-stream")
fmt.Fprintln(w, `{"healthy": true}`)
},
)
}
1 change: 1 addition & 0 deletions internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func Run(ctx context.Context, environment []string, secret func(name string) (st
notifyService := notify.New(ctx, backend)

mux := http.NewServeMux()
icchttp.HandleHealth(mux)
notify.HandleReceive(mux, notifyService, auth)
notify.HandlePublish(mux, notifyService, auth)

Expand Down

0 comments on commit e38eac0

Please sign in to comment.