Skip to content

Commit 10645ee

Browse files
ani1311aalur
andauthored
Feature: Add health check (#79)
Co-authored-by: aalur <[email protected]>
1 parent 5e5394f commit 10645ee

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

server.go

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func (app *App) StartServer(ctx context.Context, applicationPort string) error {
1818
name := "tbd" // TODO: Add a name field to "App"
1919
mux := http.NewServeMux()
2020
mux.HandleFunc("/", app.handleRequest)
21+
mux.HandleFunc("/health", HealthCheck)
2122

2223
server := &http.Server{
2324
Addr: applicationPort,
@@ -44,6 +45,10 @@ func (app *App) StartServer(ctx context.Context, applicationPort string) error {
4445
}
4546
}
4647

48+
func HealthCheck(w http.ResponseWriter, _ *http.Request) {
49+
w.WriteHeader(http.StatusOK)
50+
}
51+
4752
func (app *App) handleRequest(w http.ResponseWriter, r *http.Request) {
4853
if r.Method != http.MethodPost {
4954
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)

0 commit comments

Comments
 (0)