summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEthel Morgan <eth@ethulhu.co.uk>2020-07-07 22:11:01 +0100
committerEthel Morgan <eth@ethulhu.co.uk>2020-07-07 22:11:01 +0100
commitbad6e92e8450d9c70db55e507a4488770a10f89a (patch)
tree9b807a29f4d625311eb4617e493bed85d4009801
parentacbd480721aafbfc2c7dc923da4bc9f6db585ad0 (diff)
parse the form for loggingHEADv0.0.5latest
Diffstat (limited to '')
-rw-r--r--logger.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/logger.go b/logger.go
index d1a22ea..b725146 100644
--- a/logger.go
+++ b/logger.go
@@ -24,6 +24,11 @@ func (rw *responseWriter) WriteHeader(code int) {
rw.ResponseWriter.WriteHeader(code)
}
+const (
+ kb = 1024
+ mb = 1024 * kb
+)
+
// Logger is a middleware for logging HTTP requests and responses, using go.eth.moe/logger.
func Logger(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -47,6 +52,10 @@ func Logger(next http.Handler) http.Handler {
}
log.AddField(fmt.Sprintf("http.query.%s", k), vs)
}
+
+ if err := r.ParseMultipartForm(10 * mb); err != nil {
+ log.WithError(err).Error("could not parse request form")
+ }
for k, vs := range r.Form {
if len(vs) == 1 {
log.AddField(fmt.Sprintf("http.form.%s", k), vs[0])