Skip to content

Instantly share code, notes, and snippets.

@bruskiza
Created September 7, 2021 21:27
Show Gist options
  • Save bruskiza/7958c647ba427da4471cd5108c32bdeb to your computer and use it in GitHub Desktop.
Save bruskiza/7958c647ba427da4471cd5108c32bdeb to your computer and use it in GitHub Desktop.
Go Reflector
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