Skip to content

Instantly share code, notes, and snippets.

@mdwhatcott
Created September 21, 2015 21:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mdwhatcott/52e4736f54ed6b746264 to your computer and use it in GitHub Desktop.
HTTP server that dumps the over-the-wire HTTP request it serves.
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
)
func main() {
http.HandleFunc("/", func(response http.ResponseWriter, request *http.Request) {
dump, err := httputil.DumpRequest(request, true)
if err != nil {
response.WriteHeader(500)
} else {
fmt.Fprint(response, string(dump))
}
})
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment