Created
July 4, 2020 09:34
-
-
Save lotusirous/43d2948f0b3310db0d2d6d9ecb2f4ee5 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" | |
| "log" | |
| "net/http" | |
| "net/http/httputil" | |
| ) | |
| // HandleDump returns an http.HandlerFunc that processes an http.Request | |
| // to return a raw content from request. | |
| func HandleDump() http.HandlerFunc { | |
| return func(w http.ResponseWriter, r *http.Request) { | |
| b, err := httputil.DumpRequest(r, true) | |
| if err != nil { | |
| fmt.Fprintf(w, "internal error: %v\n", err) | |
| return | |
| } | |
| w.Write(b) | |
| } | |
| } | |
| func main() { | |
| addr := ":1234" | |
| r := http.NewServeMux() | |
| r.Handle("/", HandleDump()) | |
| svr := &http.Server{ | |
| Addr: addr, | |
| Handler: r, | |
| } | |
| log.Println("server started", addr) | |
| log.Fatal(svr.ListenAndServe()) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following is a raw request of multipart/mixed performed by curl