summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/echo.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-09-07 22:46:58 +0200
committerGitHub <noreply@github.com>2019-09-07 22:46:58 +0200
commita3bee01e0af3394c19360b98fd2db1b647f49299 (patch)
treeffc5778361d55d592a718354a37c9251e75fc7f6 /vendor/github.com/labstack/echo/v4/echo.go
parent1dc93ec4f001edd01daccbe408767d4878be25a3 (diff)
downloadmatterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.tar.gz
matterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.tar.bz2
matterbridge-msglm-a3bee01e0af3394c19360b98fd2db1b647f49299.zip
Update dependencies (#886)
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/echo.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/echo.go43
1 files changed, 22 insertions, 21 deletions
diff --git a/vendor/github.com/labstack/echo/v4/echo.go b/vendor/github.com/labstack/echo/v4/echo.go
index 56b2cf8c..552c7a78 100644
--- a/vendor/github.com/labstack/echo/v4/echo.go
+++ b/vendor/github.com/labstack/echo/v4/echo.go
@@ -99,9 +99,9 @@ type (
// HTTPError represents an error that occurred while handling a request.
HTTPError struct {
- Code int
- Message interface{}
- Internal error // Stores the error returned by an external dependency
+ Code int `json:"-"`
+ Message interface{} `json:"message"`
+ Internal error `json:"-"` // Stores the error returned by an external dependency
}
// MiddlewareFunc defines a function to process middleware.
@@ -222,11 +222,12 @@ const (
HeaderContentSecurityPolicy = "Content-Security-Policy"
HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"
HeaderXCSRFToken = "X-CSRF-Token"
+ HeaderReferrerPolicy = "Referrer-Policy"
)
const (
// Version of Echo
- Version = "4.1.5"
+ Version = "4.1.10"
website = "https://echo.labstack.com"
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
banner = `
@@ -340,32 +341,31 @@ func (e *Echo) Routers() map[string]*Router {
// DefaultHTTPErrorHandler is the default HTTP error handler. It sends a JSON response
// with status code.
func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
- var (
- code = http.StatusInternalServerError
- msg interface{}
- )
-
- if he, ok := err.(*HTTPError); ok {
- code = he.Code
- msg = he.Message
+ he, ok := err.(*HTTPError)
+ if ok {
if he.Internal != nil {
- err = fmt.Errorf("%v, %v", err, he.Internal)
+ if herr, ok := he.Internal.(*HTTPError); ok {
+ he = herr
+ }
}
- } else if e.Debug {
- msg = err.Error()
} else {
- msg = http.StatusText(code)
+ he = &HTTPError{
+ Code: http.StatusInternalServerError,
+ Message: http.StatusText(http.StatusInternalServerError),
+ }
}
- if _, ok := msg.(string); ok {
- msg = Map{"message": msg}
+ if e.Debug {
+ he.Message = err.Error()
+ } else if m, ok := he.Message.(string); ok {
+ he.Message = Map{"message": m}
}
// Send response
if !c.Response().Committed {
if c.Request().Method == http.MethodHead { // Issue #608
- err = c.NoContent(code)
+ err = c.NoContent(he.Code)
} else {
- err = c.JSON(code, msg)
+ err = c.JSON(he.Code, he.Message)
}
if err != nil {
e.Logger.Error(err)
@@ -748,7 +748,7 @@ func NewHTTPError(code int, message ...interface{}) *HTTPError {
// Error makes it compatible with `error` interface.
func (he *HTTPError) Error() string {
- return fmt.Sprintf("code=%d, message=%v", he.Code, he.Message)
+ return fmt.Sprintf("code=%d, message=%v, internal=%v", he.Code, he.Message, he.Internal)
}
// SetInternal sets error to HTTPError.Internal
@@ -771,6 +771,7 @@ func WrapMiddleware(m func(http.Handler) http.Handler) MiddlewareFunc {
return func(c Context) (err error) {
m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c.SetRequest(r)
+ c.SetResponse(NewResponse(w, c.Echo()))
err = next(c)
})).ServeHTTP(c.Response(), c.Request())
return