Created
December 30, 2018 10:44
-
-
Save kjmkznr/54f3de86a2ab241a792f66e9ea75beea to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"bytes" | |
"flag" | |
"io" | |
"log" | |
"net/http" | |
"strconv" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
var buf bytes.Buffer | |
mw := io.MultiWriter(w, &buf) | |
r.Write(mw) | |
log.Print(buf.String()) | |
} | |
func main() { | |
port := flag.Int("port", 8080, "Listen on port") | |
flag.Parse() | |
http.HandleFunc("/", handler) | |
log.Println("Starting http server on port:", *port) | |
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment