HTTP server that dumps the over-the-wire HTTP request it serves.
This file contains 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