-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (36 loc) · 798 Bytes
/
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"
"net/http"
"net/http/httputil"
"os"
)
func main() {
log.Println("Starting header-dump server ...")
httpListenPort := os.Getenv("PORT")
if httpListenPort == "" {
httpListenPort = "8080"
}
hostPort := net.JoinHostPort("0.0.0.0", httpListenPort)
mux := http.NewServeMux()
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
return
})
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Save a copy of this request for debugging.
requestDump, err := httputil.DumpRequest(r, true)
if err != nil {
fmt.Println(err)
}
fmt.Fprintf(w, string(requestDump))
})
s := &http.Server{
Addr: hostPort,
Handler: mux,
}
if err := s.ListenAndServe(); err != nil {
log.Fatal(err)
}
}