4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-09-06 10:14:10 +00:00

Update vendor labstack/echo

This commit is contained in:
Wim
2017-12-07 23:00:56 +01:00
parent 434393d1c3
commit 5c919e6bff
17 changed files with 335 additions and 143 deletions

View File

@@ -11,11 +11,12 @@ type (
// by an HTTP handler to construct an HTTP response.
// See: https://golang.org/pkg/net/http/#ResponseWriter
Response struct {
Writer http.ResponseWriter
Status int
Size int64
Committed bool
echo *Echo
echo *Echo
beforeFuncs []func()
Writer http.ResponseWriter
Status int
Size int64
Committed bool
}
)
@@ -34,6 +35,11 @@ func (r *Response) Header() http.Header {
return r.Writer.Header()
}
// Before registers a function which is called just before the response is written.
func (r *Response) Before(fn func()) {
r.beforeFuncs = append(r.beforeFuncs, fn)
}
// WriteHeader sends an HTTP response header with status code. If WriteHeader is
// not called explicitly, the first call to Write will trigger an implicit
// WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly
@@ -43,6 +49,9 @@ func (r *Response) WriteHeader(code int) {
r.echo.Logger.Warn("response already committed")
return
}
for _, fn := range r.beforeFuncs {
fn()
}
r.Status = code
r.Writer.WriteHeader(code)
r.Committed = true