aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gorilla/handlers/logging.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-11-06 01:20:46 +0000
committerTaras Madan <tarasmadan@google.com>2023-11-06 10:59:50 +0000
commit78fae24ecb7ff84a4eec0a96bb9a343c1a5e19aa (patch)
tree6fa22f6be1d55885661d53f0e5397cfc00ebb712 /vendor/github.com/gorilla/handlers/logging.go
parent1ac37bad9c41d00140a61a4a5dddc45a50ff4c62 (diff)
mod: do: bump github.com/gorilla/handlers from 1.5.1 to 1.5.2
Bumps [github.com/gorilla/handlers](https://github.com/gorilla/handlers) from 1.5.1 to 1.5.2. - [Release notes](https://github.com/gorilla/handlers/releases) - [Commits](https://github.com/gorilla/handlers/compare/v1.5.1...v1.5.2) --- updated-dependencies: - dependency-name: github.com/gorilla/handlers dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/gorilla/handlers/logging.go')
-rw-r--r--vendor/github.com/gorilla/handlers/logging.go32
1 files changed, 17 insertions, 15 deletions
diff --git a/vendor/github.com/gorilla/handlers/logging.go b/vendor/github.com/gorilla/handlers/logging.go
index 228465eba..2badb6fbf 100644
--- a/vendor/github.com/gorilla/handlers/logging.go
+++ b/vendor/github.com/gorilla/handlers/logging.go
@@ -18,7 +18,7 @@ import (
// Logging
-// LogFormatterParams is the structure any formatter will be handed when time to log comes
+// LogFormatterParams is the structure any formatter will be handed when time to log comes.
type LogFormatterParams struct {
Request *http.Request
URL url.URL
@@ -27,7 +27,7 @@ type LogFormatterParams struct {
Size int
}
-// LogFormatter gives the signature of the formatter function passed to CustomLoggingHandler
+// LogFormatter gives the signature of the formatter function passed to CustomLoggingHandler.
type LogFormatter func(writer io.Writer, params LogFormatterParams)
// loggingHandler is the http.Handler implementation for LoggingHandlerTo and its
@@ -46,7 +46,10 @@ func (h loggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
h.handler.ServeHTTP(w, req)
if req.MultipartForm != nil {
- req.MultipartForm.RemoveAll()
+ err := req.MultipartForm.RemoveAll()
+ if err != nil {
+ return
+ }
}
params := LogFormatterParams{
@@ -76,7 +79,7 @@ const lowerhex = "0123456789abcdef"
func appendQuoted(buf []byte, s string) []byte {
var runeTmp [utf8.UTFMax]byte
- for width := 0; len(s) > 0; s = s[width:] {
+ for width := 0; len(s) > 0; s = s[width:] { //nolint: wastedassign //TODO: why width starts from 0and reassigned as 1
r := rune(s[0])
width = 1
if r >= utf8.RuneSelf {
@@ -191,7 +194,7 @@ func buildCommonLogLine(req *http.Request, url url.URL, ts time.Time, status int
func writeLog(writer io.Writer, params LogFormatterParams) {
buf := buildCommonLogLine(params.Request, params.URL, params.TimeStamp, params.StatusCode, params.Size)
buf = append(buf, '\n')
- writer.Write(buf)
+ _, _ = writer.Write(buf)
}
// writeCombinedLog writes a log entry for req to w in Apache Combined Log Format.
@@ -204,7 +207,7 @@ func writeCombinedLog(writer io.Writer, params LogFormatterParams) {
buf = append(buf, `" "`...)
buf = appendQuoted(buf, params.Request.UserAgent())
buf = append(buf, '"', '\n')
- writer.Write(buf)
+ _, _ = writer.Write(buf)
}
// CombinedLoggingHandler return a http.Handler that wraps h and logs requests to out in
@@ -212,7 +215,7 @@ func writeCombinedLog(writer io.Writer, params LogFormatterParams) {
//
// See http://httpd.apache.org/docs/2.2/logs.html#combined for a description of this format.
//
-// LoggingHandler always sets the ident field of the log to -
+// LoggingHandler always sets the ident field of the log to -.
func CombinedLoggingHandler(out io.Writer, h http.Handler) http.Handler {
return loggingHandler{out, h, writeCombinedLog}
}
@@ -226,19 +229,18 @@ func CombinedLoggingHandler(out io.Writer, h http.Handler) http.Handler {
//
// Example:
//
-// r := mux.NewRouter()
-// r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
-// w.Write([]byte("This is a catch-all route"))
-// })
-// loggedRouter := handlers.LoggingHandler(os.Stdout, r)
-// http.ListenAndServe(":1123", loggedRouter)
-//
+// r := mux.NewRouter()
+// r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+// w.Write([]byte("This is a catch-all route"))
+// })
+// loggedRouter := handlers.LoggingHandler(os.Stdout, r)
+// http.ListenAndServe(":1123", loggedRouter)
func LoggingHandler(out io.Writer, h http.Handler) http.Handler {
return loggingHandler{out, h, writeLog}
}
// CustomLoggingHandler provides a way to supply a custom log formatter
-// while taking advantage of the mechanisms in this package
+// while taking advantage of the mechanisms in this package.
func CustomLoggingHandler(out io.Writer, h http.Handler, f LogFormatter) http.Handler {
return loggingHandler{out, h, f}
}