summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/context.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/context.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/vendor/github.com/labstack/echo/v4/context.go b/vendor/github.com/labstack/echo/v4/context.go
index 27da5ffe..99ef03bc 100644
--- a/vendor/github.com/labstack/echo/v4/context.go
+++ b/vendor/github.com/labstack/echo/v4/context.go
@@ -43,6 +43,7 @@ type (
// RealIP returns the client's network address based on `X-Forwarded-For`
// or `X-Real-IP` request header.
+ // The behavior can be configured using `Echo#IPExtractor`.
RealIP() string
// Path returns the registered path for the handler.
@@ -270,6 +271,10 @@ func (c *context) Scheme() string {
}
func (c *context) RealIP() string {
+ if c.echo != nil && c.echo.IPExtractor != nil {
+ return c.echo.IPExtractor(c.request)
+ }
+ // Fall back to legacy behavior
if ip := c.request.Header.Get(HeaderXForwardedFor); ip != "" {
return strings.Split(ip, ", ")[0]
}
@@ -305,6 +310,7 @@ func (c *context) ParamNames() []string {
func (c *context) SetParamNames(names ...string) {
c.pnames = names
+ *c.echo.maxParam = len(names)
}
func (c *context) ParamValues() []string {
@@ -352,8 +358,11 @@ func (c *context) FormParams() (url.Values, error) {
func (c *context) FormFile(name string) (*multipart.FileHeader, error) {
f, fh, err := c.request.FormFile(name)
+ if err != nil {
+ return nil, err
+ }
defer f.Close()
- return fh, err
+ return fh, nil
}
func (c *context) MultipartForm() (*multipart.Form, error) {