-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
35 lines (29 loc) · 755 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
package main
import (
"fmt"
"net/http"
"os"
"github.com/henvic/httpretty"
)
func main() {
logger := &httpretty.Logger{
Time: true,
TLS: true,
RequestHeader: true,
RequestBody: true,
ResponseHeader: true,
ResponseBody: true,
Colors: true, // erase line if you don't like colors
}
addr := ":8090"
fmt.Printf("Open http://localhost%s in the browser.\n", addr)
/* #nosec G114 Ignore timeout */
if err := http.ListenAndServe(addr, logger.Middleware(helloHandler{})); err != http.ErrServerClosed {
fmt.Fprintln(os.Stderr, err)
}
}
type helloHandler struct{}
func (h helloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header()["Date"] = nil
fmt.Fprintf(w, "Hello, world!")
}