-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (39 loc) · 1.08 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"time"
)
func health(w http.ResponseWriter, r *http.Request) {
val := `
888 888 888
888 888 888
888 888 888
888d888 .d88b. .d88888 88888b. 8888b. 888888
888P" d8P Y8bd88" 888 888 "88b "88b888
888 88888888888 888 888 888.d888888888
888 Y8b. Y88b 888 888 888888 888Y88b.
888 "Y8888 "Y88888 888 888"Y888888 "Y888
`
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, val)
}
func dump(w http.ResponseWriter, r *http.Request) {
// Simulate at least a bit of processing time.
time.Sleep(100 * time.Millisecond)
w.WriteHeader(http.StatusOK)
if reqBytes, err := httputil.DumpRequest(r, true); err == nil {
log.Printf("Openshift Http Request Dumper received a message: %+v", string(reqBytes))
w.Write(reqBytes)
} else {
log.Printf("Error dumping the request: %+v :: %+v", err, r)
}
}
func main() {
m := http.NewServeMux()
m.HandleFunc("/", dump)
m.HandleFunc("/health", health)
http.ListenAndServe(":8080", m)
}