Last active
January 7, 2020 03:12
-
-
Save lwzm/5615121a26fb50df381d16e6c5cb195f 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" | |
"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