Created
September 21, 2015 21:44
-
-
Save mdwhatcott/52e4736f54ed6b746264 to your computer and use it in GitHub Desktop.
HTTP server that dumps the over-the-wire HTTP request it serves.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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