mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] Bump go swagger (#2871)
* bump go swagger version * bump swagger version
This commit is contained in:
32
vendor/github.com/gorilla/handlers/logging.go
generated
vendored
32
vendor/github.com/gorilla/handlers/logging.go
generated
vendored
@ -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}
|
||||
}
|
||||
|
Reference in New Issue
Block a user