Created
April 17, 2017 18:23
-
-
Save empijei/c1117a074372b905832cc1f804309343 to your computer and use it in GitHub Desktop.
dump http requests
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 ( | |
"fmt" | |
"log" | |
"net/http" | |
"net/http/httputil" | |
"os" | |
) | |
type cHandler struct{} | |
var customhandler = &cHandler{} | |
func (c *cHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
buf, _ := httputil.DumpRequest(r, true) | |
fmt.Println(string(buf)) | |
http.DefaultServeMux.ServeHTTP(w, r) | |
} | |
func main() { | |
port := os.Getenv("PORT") | |
if port == "" { | |
log.Fatal("$PORT must be set") | |
} | |
http.Handle("/website/", http.StripPrefix("/website/", http.FileServer(http.Dir("website")))) | |
_ = http.ListenAndServe(":"+port, customhandler) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment