Add reply logging
This commit is contained in:
parent
b449132ba4
commit
50dae8f4f6
|
@ -10,6 +10,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fileRoute matches /files/<id>. Go seems to use \r to terminate header
|
// fileRoute matches /files/<id>. Go seems to use \r to terminate header
|
||||||
|
@ -66,6 +67,7 @@ func serveHttp() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func route(w http.ResponseWriter, r *http.Request) {
|
func route(w http.ResponseWriter, r *http.Request) {
|
||||||
|
start := time.Now()
|
||||||
log.Printf("request: %s %s", r.Method, r.URL.RequestURI())
|
log.Printf("request: %s %s", r.Method, r.URL.RequestURI())
|
||||||
|
|
||||||
w.Header().Set("Server", "tusd")
|
w.Header().Set("Server", "tusd")
|
||||||
|
@ -99,6 +101,9 @@ func route(w http.ResponseWriter, r *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
reply(w, http.StatusNotFound, "No matching route")
|
reply(w, http.StatusNotFound, "No matching route")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
duration := time.Since(start)
|
||||||
|
log.Printf("finished: %s %s (took %s)", r.Method, r.URL.RequestURI(), duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reply(w http.ResponseWriter, code int, message string) {
|
func reply(w http.ResponseWriter, code int, message string) {
|
||||||
|
|
Loading…
Reference in New Issue