summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack
diff options
context:
space:
mode:
authorWim <wim@42.be>2021-05-05 22:03:28 +0200
committerGitHub <noreply@github.com>2021-05-05 22:03:28 +0200
commita0bca42a7ad98a37f4bdc4d7adc419471163edfb (patch)
tree3e87fdb61128039b016adb4e586636484c63ed52 /vendor/github.com/labstack
parentaf543dcd05cfb5341311e2e214727e26411d2f92 (diff)
downloadmatterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.tar.gz
matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.tar.bz2
matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.zip
Update vendor (#1461)
* Update vendored libs * Fix slack api changes
Diffstat (limited to 'vendor/github.com/labstack')
-rw-r--r--vendor/github.com/labstack/echo/v4/CHANGELOG.md10
-rw-r--r--vendor/github.com/labstack/echo/v4/bind.go4
-rw-r--r--vendor/github.com/labstack/echo/v4/echo.go2
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/middleware.go46
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/proxy.go5
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/redirect.go45
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/rewrite.go6
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/timeout.go9
8 files changed, 77 insertions, 50 deletions
diff --git a/vendor/github.com/labstack/echo/v4/CHANGELOG.md b/vendor/github.com/labstack/echo/v4/CHANGELOG.md
index b5047883..c1be77a9 100644
--- a/vendor/github.com/labstack/echo/v4/CHANGELOG.md
+++ b/vendor/github.com/labstack/echo/v4/CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog
+## v4.2.2 - 2020-04-07
+
+**Fixes**
+
+* Allow proxy middleware to use query part in rewrite (#1802)
+* Fix timeout middleware not sending status code when handler returns an error (#1805)
+* Fix Bind() when target is array/slice and path/query params complains bind target not being struct (#1835)
+* Fix panic in redirect middleware on short host name (#1813)
+* Fix timeout middleware docs (#1836)
+
## v4.2.1 - 2020-03-08
**Important notes**
diff --git a/vendor/github.com/labstack/echo/v4/bind.go b/vendor/github.com/labstack/echo/v4/bind.go
index 16c3b7ad..08d39891 100644
--- a/vendor/github.com/labstack/echo/v4/bind.go
+++ b/vendor/github.com/labstack/echo/v4/bind.go
@@ -134,6 +134,10 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
// !struct
if typ.Kind() != reflect.Struct {
+ if tag == "param" || tag == "query" {
+ // incompatible type, data is probably to be found in the body
+ return nil
+ }
return errors.New("binding element must be a struct")
}
diff --git a/vendor/github.com/labstack/echo/v4/echo.go b/vendor/github.com/labstack/echo/v4/echo.go
index 3fccaf64..a24e3977 100644
--- a/vendor/github.com/labstack/echo/v4/echo.go
+++ b/vendor/github.com/labstack/echo/v4/echo.go
@@ -234,7 +234,7 @@ const (
const (
// Version of Echo
- Version = "4.2.1"
+ Version = "4.2.2"
website = "https://echo.labstack.com"
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
banner = `
diff --git a/vendor/github.com/labstack/echo/v4/middleware/middleware.go b/vendor/github.com/labstack/echo/v4/middleware/middleware.go
index 6bdb0eb7..a7ad73a5 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/middleware.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/middleware.go
@@ -2,7 +2,6 @@ package middleware
import (
"net/http"
- "net/url"
"regexp"
"strconv"
"strings"
@@ -49,30 +48,39 @@ func rewriteRulesRegex(rewrite map[string]string) map[*regexp.Regexp]string {
return rulesRegex
}
-func rewritePath(rewriteRegex map[*regexp.Regexp]string, req *http.Request) {
- for k, v := range rewriteRegex {
- rawPath := req.URL.RawPath
- if rawPath != "" {
- // RawPath is only set when there has been escaping done. In that case Path must be deduced from rewritten RawPath
- // because encoded Path could match rules that RawPath did not
- if replacer := captureTokens(k, rawPath); replacer != nil {
- rawPath = replacer.Replace(v)
-
- req.URL.RawPath = rawPath
- req.URL.Path, _ = url.PathUnescape(rawPath)
-
- return // rewrite only once
- }
+func rewriteURL(rewriteRegex map[*regexp.Regexp]string, req *http.Request) error {
+ if len(rewriteRegex) == 0 {
+ return nil
+ }
- continue
+ // Depending how HTTP request is sent RequestURI could contain Scheme://Host/path or be just /path.
+ // We only want to use path part for rewriting and therefore trim prefix if it exists
+ rawURI := req.RequestURI
+ if rawURI != "" && rawURI[0] != '/' {
+ prefix := ""
+ if req.URL.Scheme != "" {
+ prefix = req.URL.Scheme + "://"
}
+ if req.URL.Host != "" {
+ prefix += req.URL.Host // host or host:port
+ }
+ if prefix != "" {
+ rawURI = strings.TrimPrefix(rawURI, prefix)
+ }
+ }
- if replacer := captureTokens(k, req.URL.Path); replacer != nil {
- req.URL.Path = replacer.Replace(v)
+ for k, v := range rewriteRegex {
+ if replacer := captureTokens(k, rawURI); replacer != nil {
+ url, err := req.URL.Parse(replacer.Replace(v))
+ if err != nil {
+ return err
+ }
+ req.URL = url
- return // rewrite only once
+ return nil // rewrite only once
}
}
+ return nil
}
// DefaultSkipper returns false which processes the middleware.
diff --git a/vendor/github.com/labstack/echo/v4/middleware/proxy.go b/vendor/github.com/labstack/echo/v4/middleware/proxy.go
index 63eec5a2..6f01f3a7 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/proxy.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/proxy.go
@@ -231,8 +231,9 @@ func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc {
tgt := config.Balancer.Next(c)
c.Set(config.ContextKey, tgt)
- // Set rewrite path and raw path
- rewritePath(config.RegexRewrite, req)
+ if err := rewriteURL(config.RegexRewrite, req); err != nil {
+ return err
+ }
// Fix header
// Basically it's not good practice to unconditionally pass incoming x-real-ip header to upstream.
diff --git a/vendor/github.com/labstack/echo/v4/middleware/redirect.go b/vendor/github.com/labstack/echo/v4/middleware/redirect.go
index 813e5b85..13877db3 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/redirect.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/redirect.go
@@ -2,6 +2,7 @@ package middleware
import (
"net/http"
+ "strings"
"github.com/labstack/echo/v4"
)
@@ -40,11 +41,11 @@ func HTTPSRedirect() echo.MiddlewareFunc {
// HTTPSRedirectWithConfig returns an HTTPSRedirect middleware with config.
// See `HTTPSRedirect()`.
func HTTPSRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc {
- return redirect(config, func(scheme, host, uri string) (ok bool, url string) {
- if ok = scheme != "https"; ok {
- url = "https://" + host + uri
+ return redirect(config, func(scheme, host, uri string) (bool, string) {
+ if scheme != "https" {
+ return true, "https://" + host + uri
}
- return
+ return false, ""
})
}
@@ -59,11 +60,11 @@ func HTTPSWWWRedirect() echo.MiddlewareFunc {
// HTTPSWWWRedirectWithConfig returns an HTTPSRedirect middleware with config.
// See `HTTPSWWWRedirect()`.
func HTTPSWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc {
- return redirect(config, func(scheme, host, uri string) (ok bool, url string) {
- if ok = scheme != "https" && host[:4] != www; ok {
- url = "https://www." + host + uri
+ return redirect(config, func(scheme, host, uri string) (bool, string) {
+ if scheme != "https" && !strings.HasPrefix(host, www) {
+ return true, "https://www." + host + uri
}
- return
+ return false, ""
})
}
@@ -79,13 +80,11 @@ func HTTPSNonWWWRedirect() echo.MiddlewareFunc {
// See `HTTPSNonWWWRedirect()`.
func HTTPSNonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc {
return redirect(config, func(scheme, host, uri string) (ok bool, url string) {
- if ok = scheme != "https"; ok {
- if host[:4] == www {
- host = host[4:]
- }
- url = "https://" + host + uri
+ if scheme != "https" {
+ host = strings.TrimPrefix(host, www)
+ return true, "https://" + host + uri
}
- return
+ return false, ""
})
}
@@ -100,11 +99,11 @@ func WWWRedirect() echo.MiddlewareFunc {
// WWWRedirectWithConfig returns an HTTPSRedirect middleware with config.
// See `WWWRedirect()`.
func WWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc {
- return redirect(config, func(scheme, host, uri string) (ok bool, url string) {
- if ok = host[:4] != www; ok {
- url = scheme + "://www." + host + uri
+ return redirect(config, func(scheme, host, uri string) (bool, string) {
+ if !strings.HasPrefix(host, www) {
+ return true, scheme + "://www." + host + uri
}
- return
+ return false, ""
})
}
@@ -119,17 +118,17 @@ func NonWWWRedirect() echo.MiddlewareFunc {
// NonWWWRedirectWithConfig returns an HTTPSRedirect middleware with config.
// See `NonWWWRedirect()`.
func NonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc {
- return redirect(config, func(scheme, host, uri string) (ok bool, url string) {
- if ok = host[:4] == www; ok {
- url = scheme + "://" + host[4:] + uri
+ return redirect(config, func(scheme, host, uri string) (bool, string) {
+ if strings.HasPrefix(host, www) {
+ return true, scheme + "://" + host[4:] + uri
}
- return
+ return false, ""
})
}
func redirect(config RedirectConfig, cb redirectLogic) echo.MiddlewareFunc {
if config.Skipper == nil {
- config.Skipper = DefaultTrailingSlashConfig.Skipper
+ config.Skipper = DefaultRedirectConfig.Skipper
}
if config.Code == 0 {
config.Code = DefaultRedirectConfig.Code
diff --git a/vendor/github.com/labstack/echo/v4/middleware/rewrite.go b/vendor/github.com/labstack/echo/v4/middleware/rewrite.go
index c05d5d84..e5b0a6b5 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/rewrite.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/rewrite.go
@@ -72,9 +72,9 @@ func RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc {
return next(c)
}
- req := c.Request()
- // Set rewrite path and raw path
- rewritePath(config.RegexRules, req)
+ if err := rewriteURL(config.RegexRules, c.Request()); err != nil {
+ return err
+ }
return next(c)
}
}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/timeout.go b/vendor/github.com/labstack/echo/v4/middleware/timeout.go
index 68f464e4..5d23ff45 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/timeout.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/timeout.go
@@ -42,8 +42,8 @@ var (
}
)
-// Timeout returns a middleware which recovers from panics anywhere in the chain
-// and handles the control to the centralized HTTPErrorHandler.
+// Timeout returns a middleware which returns error (503 Service Unavailable error) to client immediately when handler
+// call runs for longer than its time limit. NB: timeout does not stop handler execution.
func Timeout() echo.MiddlewareFunc {
return TimeoutWithConfig(DefaultTimeoutConfig)
}
@@ -106,6 +106,11 @@ func (t echoHandlerFuncWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Reques
// so on timeout writer stays what http.TimeoutHandler uses and prevents writing headers/body
t.ctx.Response().Writer = originalWriter
if err != nil {
+ // call global error handler to write error to the client. This is needed or `http.TimeoutHandler` will send status code by itself
+ // and after that our tries to write status code will not work anymore
+ t.ctx.Error(err)
+ // we pass error from handler to middlewares up in handler chain to act on it if needed. But this means that
+ // global error handler is probably be called twice as `t.ctx.Error` already does that.
t.errChan <- err
}
}