Skip to content

Commit

Permalink
Feature: Add health check (#79)
Browse files Browse the repository at this point in the history
Co-authored-by: aalur <[email protected]>
  • Loading branch information
ani1311 and aalur authored Sep 4, 2024
1 parent 5e5394f commit 10645ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (app *App) StartServer(ctx context.Context, applicationPort string) error {
name := "tbd" // TODO: Add a name field to "App"
mux := http.NewServeMux()
mux.HandleFunc("/", app.handleRequest)
mux.HandleFunc("/health", HealthCheck)

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

func HealthCheck(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}

func (app *App) handleRequest(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
Expand Down

0 comments on commit 10645ee

Please sign in to comment.