diff options
author | Wim <wim@42.be> | 2021-07-31 18:27:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-31 18:27:55 +0200 |
commit | 44f3e2557dad86129419ed098c29e67638519f4f (patch) | |
tree | 17b8ddba49057cd8bf39cdf2618b31c7f6bc8c6a /vendor/github.com/labstack/echo/v4/context.go | |
parent | 1f365c716eae44b64dc5bdace5cb70441d7eb4c2 (diff) | |
download | matterbridge-msglm-44f3e2557dad86129419ed098c29e67638519f4f.tar.gz matterbridge-msglm-44f3e2557dad86129419ed098c29e67638519f4f.tar.bz2 matterbridge-msglm-44f3e2557dad86129419ed098c29e67638519f4f.zip |
Update vendor (#1560)
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/context.go')
-rw-r--r-- | vendor/github.com/labstack/echo/v4/context.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/vendor/github.com/labstack/echo/v4/context.go b/vendor/github.com/labstack/echo/v4/context.go index 0cee48ce..91ab6e48 100644 --- a/vendor/github.com/labstack/echo/v4/context.go +++ b/vendor/github.com/labstack/echo/v4/context.go @@ -2,7 +2,6 @@ package echo import ( "bytes" - "encoding/json" "encoding/xml" "fmt" "io" @@ -276,9 +275,9 @@ func (c *context) RealIP() string { } // Fall back to legacy behavior if ip := c.request.Header.Get(HeaderXForwardedFor); ip != "" { - i := strings.IndexAny(ip, ", ") + i := strings.IndexAny(ip, ",") if i > 0 { - return ip[:i] + return strings.TrimSpace(ip[:i]) } return ip } @@ -457,17 +456,16 @@ func (c *context) String(code int, s string) (err error) { } func (c *context) jsonPBlob(code int, callback string, i interface{}) (err error) { - enc := json.NewEncoder(c.response) - _, pretty := c.QueryParams()["pretty"] - if c.echo.Debug || pretty { - enc.SetIndent("", " ") + indent := "" + if _, pretty := c.QueryParams()["pretty"]; c.echo.Debug || pretty { + indent = defaultIndent } c.writeContentType(MIMEApplicationJavaScriptCharsetUTF8) c.response.WriteHeader(code) if _, err = c.response.Write([]byte(callback + "(")); err != nil { return } - if err = enc.Encode(i); err != nil { + if err = c.echo.JSONSerializer.Serialize(c, i, indent); err != nil { return } if _, err = c.response.Write([]byte(");")); err != nil { @@ -477,13 +475,9 @@ func (c *context) jsonPBlob(code int, callback string, i interface{}) (err error } func (c *context) json(code int, i interface{}, indent string) error { - enc := json.NewEncoder(c.response) - if indent != "" { - enc.SetIndent("", indent) - } c.writeContentType(MIMEApplicationJSONCharsetUTF8) c.response.Status = code - return enc.Encode(i) + return c.echo.JSONSerializer.Serialize(c, i, indent) } func (c *context) JSON(code int, i interface{}) (err error) { |