Created
September 7, 2021 21:27
-
-
Save bruskiza/7958c647ba427da4471cd5108c32bdeb to your computer and use it in GitHub Desktop.
Go Reflector
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 echoer(w http.ResponseWriter, r *http.Request) { | |
log.Printf("Received request") | |
requestDump, err := httputil.DumpRequest(r, true) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(string(requestDump)) | |
fmt.Fprintf(w, string(requestDump)) | |
fmt.Fprintf(w, "\n\n-- END --\n") | |
log.Printf("Done") | |
} | |
func handleRequests() { | |
http.HandleFunc("/", echoer) | |
log.Fatal(http.ListenAndServe(":10000", nil)) | |
} | |
func main() { | |
log.Printf("Started") | |
handleRequests() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment