Skip to content

Instantly share code, notes, and snippets.

@lwzm
Last active January 7, 2020 03:12
Show Gist options
  • Save lwzm/5615121a26fb50df381d16e6c5cb195f to your computer and use it in GitHub Desktop.
Save lwzm/5615121a26fb50df381d16e6c5cb195f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func init() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
bs, _ := ioutil.ReadAll(r.Body)
s := fmt.Sprintf(
"%s %s %s%s\n%s\n",
r.RemoteAddr,
r.Method,
r.Host,
r.URL,
string(bs),
)
log.Println(s)
w.Write([]byte(s))
})
}
func main() {
log.Fatal(http.ListenAndServe(":1111", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment