Created
January 31, 2017 07:30
-
-
Save rominirani/dc5d6f5be3c6cdbc1e7a76d593719a1d to your computer and use it in GitHub Desktop.
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" | |
"github.com/gorilla/mux" | |
"log" | |
"net/http" | |
"net/http/httputil" | |
) | |
func DumpRequest(w http.ResponseWriter, req *http.Request) { | |
requestDump, err := httputil.DumpRequest(req, true) | |
if err != nil { | |
fmt.Fprint(w, err.Error()) | |
} else { | |
fmt.Fprint(w, string(requestDump)) | |
} | |
} | |
func main() { | |
router := mux.NewRouter() | |
router.HandleFunc("/dumprequestG", DumpRequest).Methods("GET") | |
router.HandleFunc("/dumprequestP", DumpRequest).Methods("POST") | |
log.Fatal(http.ListenAndServe(":12345", router)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment