Skip to content

Commit c6d838c

Browse files
authored
Merge pull request #50 from Team-MostWanted/feature/unauthenticated-health-page
Added unauthenticated health check page
2 parents b757a71 + 266f757 commit c6d838c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) with the minor change that we use a prefix instead of grouping.
55
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.22.0] - 2025-05-15
8+
- Added: unauthenticated health check page
9+
710
## [1.21.0] - 2025-04-17
811
- Added: support added for basic auth
912

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ func main() {
3232
if config.server.authUser != "" && config.server.authPW != "" {
3333
r.Handle("/", withBasicAuth(landingPage))
3434
r.Handle("/metrics", withBasicAuth(promhttp.Handler()))
35+
r.Handle("/probe", withBasicAuth(probe))
3536
} else {
3637
r.HandleFunc("/", landingPage)
3738
r.Handle("/metrics", promhttp.Handler())
39+
r.HandleFunc("/probe", probe)
3840
}
39-
r.HandleFunc("/probe", probe)
41+
r.HandleFunc("/health", health)
4042

4143
err := http.ListenAndServe(
4244
addr,

pages.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"net/http"
67
)
@@ -43,6 +44,17 @@ func landingPage(w http.ResponseWriter, r *http.Request) {
4344
}
4445
}
4546

47+
func health(w http.ResponseWriter, r *http.Request) {
48+
if r.URL.Path != "/health" {
49+
http.NotFound(w, r)
50+
return
51+
}
52+
53+
w.Header().Set("Content-Type", "application/json")
54+
json.NewEncoder(w).Encode(map[string]string{"status": "OK"})
55+
return
56+
}
57+
4658
func debugProbe(w http.ResponseWriter, probeName string, result runResult) {
4759
title := "Debug Probe " + probeName
4860

0 commit comments

Comments
 (0)