Skip to content

Commit 86b0d92

Browse files
committed
Add status/about endpoint for frontend to hit
1 parent 20733af commit 86b0d92

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

kubernetes/base/deployment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ spec:
3737
- configMapRef:
3838
name: <% .Name %>-config
3939
env:
40+
- name: POD_NAME
41+
valueFrom:
42+
fieldRef:
43+
fieldPath: metadata.name
4044
- name: DATABASE_USERNAME
4145
valueFrom:
4246
secretKeyRef:

main.go

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

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
67
"html"
78
"log"
@@ -21,6 +22,17 @@ func main() {
2122
r := http.NewServeMux()
2223
r.HandleFunc("/status/ready", readinessCheckEndpoint)
2324

25+
// Something for the example frontend to hit
26+
r.HandleFunc("/status/about", func(w http.ResponseWriter, r *http.Request) {
27+
response, err := json.Marshal(map[string]string{"podName": os.Getenv("POD_NAME")})
28+
if err == nil {
29+
w.Header().Set("Content-Type", "application/json")
30+
w.Write(response)
31+
} else {
32+
http.Error(w, err.Error(), http.StatusInternalServerError)
33+
}
34+
})
35+
2436
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
2537
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
2638
})

0 commit comments

Comments
 (0)