mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-04 08:57:44 +00:00
10
vendor/github.com/labstack/echo/v4/CHANGELOG.md
generated
vendored
10
vendor/github.com/labstack/echo/v4/CHANGELOG.md
generated
vendored
@ -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**
|
||||
|
4
vendor/github.com/labstack/echo/v4/bind.go
generated
vendored
4
vendor/github.com/labstack/echo/v4/bind.go
generated
vendored
@ -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")
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/labstack/echo/v4/echo.go
generated
vendored
2
vendor/github.com/labstack/echo/v4/echo.go
generated
vendored
@ -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 = `
|
||||
|
50
vendor/github.com/labstack/echo/v4/middleware/middleware.go
generated
vendored
50
vendor/github.com/labstack/echo/v4/middleware/middleware.go
generated
vendored
@ -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)
|
||||
func rewriteURL(rewriteRegex map[*regexp.Regexp]string, req *http.Request) error {
|
||||
if len(rewriteRegex) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
req.URL.RawPath = rawPath
|
||||
req.URL.Path, _ = url.PathUnescape(rawPath)
|
||||
|
||||
return // rewrite only once
|
||||
}
|
||||
|
||||
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 replacer := captureTokens(k, req.URL.Path); replacer != nil {
|
||||
req.URL.Path = replacer.Replace(v)
|
||||
|
||||
return // rewrite only once
|
||||
if req.URL.Host != "" {
|
||||
prefix += req.URL.Host // host or host:port
|
||||
}
|
||||
if prefix != "" {
|
||||
rawURI = strings.TrimPrefix(rawURI, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
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 nil // rewrite only once
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DefaultSkipper returns false which processes the middleware.
|
||||
|
5
vendor/github.com/labstack/echo/v4/middleware/proxy.go
generated
vendored
5
vendor/github.com/labstack/echo/v4/middleware/proxy.go
generated
vendored
@ -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.
|
||||
|
45
vendor/github.com/labstack/echo/v4/middleware/redirect.go
generated
vendored
45
vendor/github.com/labstack/echo/v4/middleware/redirect.go
generated
vendored
@ -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
|
||||
|
6
vendor/github.com/labstack/echo/v4/middleware/rewrite.go
generated
vendored
6
vendor/github.com/labstack/echo/v4/middleware/rewrite.go
generated
vendored
@ -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)
|
||||
}
|
||||
}
|
||||
|
9
vendor/github.com/labstack/echo/v4/middleware/timeout.go
generated
vendored
9
vendor/github.com/labstack/echo/v4/middleware/timeout.go
generated
vendored
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user