...
1 package main
2
3 import (
4 "fmt"
5 "net/http"
6 "os"
7
8 "github.com/henvic/httpretty"
9 )
10
11 func main() {
12 logger := &httpretty.Logger{
13 Time: true,
14 TLS: true,
15 RequestHeader: true,
16 RequestBody: true,
17 ResponseHeader: true,
18 ResponseBody: true,
19 Colors: true,
20 }
21
22 addr := ":8090"
23 fmt.Printf("Open http://localhost%s in the browser.\n", addr)
24
25 if err := http.ListenAndServe(":8090", logger.Middleware(helloHandler{})); err != http.ErrServerClosed {
26 fmt.Fprintln(os.Stderr, err)
27 }
28 }
29
30 type helloHandler struct{}
31
32 func (h helloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
33 w.Header()["Date"] = nil
34 fmt.Fprintf(w, "Hello, world!")
35 }
36
View as plain text