Created
September 14, 2016 17:58
-
-
Save ericksond/c591064b684d50f8a08dfbd933e316ec to your computer and use it in GitHub Desktop.
HTTP POST Request Dump to HTTP/1.x Wire
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(w http.ResponseWriter, r *http.Request) { | |
dump, err := httputil.DumpRequest(r, true) | |
if err != nil { | |
fmt.Println(err) | |
http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) | |
return | |
} | |
fmt.Println(string(dump)) | |
// fmt.Fprintf(w, "%q", dump) | |
}) | |
log.Fatal(http.ListenAndServe(":8080", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment