Skip to content

Instantly share code, notes, and snippets.

@s-aska
Created September 5, 2017 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-aska/4ce0f278385c939f24022102c6ade122 to your computer and use it in GitHub Desktop.
Save s-aska/4ce0f278385c939f24022102c6ade122 to your computer and use it in GitHub Desktop.
request capture
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s %s HTTP/%d/%d\n", r.Method, r.URL.Path, r.ProtoMajor, r.ProtoMinor)
r.Header.Write(w)
fmt.Fprint(w, "\n")
io.Copy(w, r.Body)
})
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment