Skip to content

Instantly share code, notes, and snippets.

@brunoluiz
Created November 10, 2020 15:19
Show Gist options
  • Save brunoluiz/b5d80496d37e4eb407f63ec39697e1d6 to your computer and use it in GitHub Desktop.
Save brunoluiz/b5d80496d37e4eb407f63ec39697e1d6 to your computer and use it in GitHub Desktop.
HTTP logger server
package main
import (
"fmt"
"net/http"
"net/http/httputil"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
dump, err := httputil.DumpRequest(r, true)
if err != nil {
fmt.Printf(">> ERROR\n%s\n", err)
return
}
fmt.Printf("\n>> REQUEST\n%s\n", dump)
})
http.ListenAndServe(":9000", mux)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment