diff --git a/Makefile b/Makefile index 509d765..427945a 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ TEST = TestRawListenerBench VERSION = DEV-$(shell date +%s) LDFLAGS = -ldflags "-X main.VERSION=$(VERSION) -extldflags \"-static\"" MAC_LDFLAGS = -ldflags "-X main.VERSION=$(VERSION)" +FADDR = ":8000" release: release-x64 release-mac @@ -68,7 +69,7 @@ run-3: sudo -E go run $(SOURCE) --input-tcp :27001 --output-stdout file-server: - go run $(SOURCE) file-server :8000 + go run $(SOURCE) file-server $(FADDR) record: $(RUN) go run $(SOURCE) --input-dummy=0 --output-file=requests.gor --verbose --debug diff --git a/gor.go b/gor.go index 66791ea..6a5f794 100644 --- a/gor.go +++ b/gor.go @@ -15,6 +15,7 @@ import ( "syscall" "time" "net/http" + "net/http/httputil" ) var ( @@ -23,6 +24,14 @@ var ( memprofile = flag.String("memprofile", "", "write memory profile to this file") ) +func loggingMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + rb, _ := httputil.DumpRequest(r, false) + log.Println(string(rb)) + next.ServeHTTP(w, r) + }) +} + func main() { // // Don't exit on panic // defer func() { @@ -45,7 +54,7 @@ func main() { log.Println("Started example file server for current dirrectory on address ", args[1]) - log.Fatal(http.ListenAndServe(args[1], http.FileServer(http.Dir(dir)))) + log.Fatal(http.ListenAndServe(args[1], loggingMiddleware(http.FileServer(http.Dir(dir))))) } else { flag.Parse() InitPlugins()