summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/response.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-12-07 23:00:56 +0100
committerWim <wim@42.be>2017-12-07 23:00:56 +0100
commit5c919e6bffbf5dbe057623323effdbed2e82189e (patch)
tree8e0130ea7387ac1a38c8ceb5b85de1f43435bbe0 /vendor/github.com/labstack/echo/response.go
parent434393d1c3ade598bd38c98eefe7db93be4c9b27 (diff)
downloadmatterbridge-msglm-5c919e6bffbf5dbe057623323effdbed2e82189e.tar.gz
matterbridge-msglm-5c919e6bffbf5dbe057623323effdbed2e82189e.tar.bz2
matterbridge-msglm-5c919e6bffbf5dbe057623323effdbed2e82189e.zip
Update vendor labstack/echo
Diffstat (limited to 'vendor/github.com/labstack/echo/response.go')
-rw-r--r--vendor/github.com/labstack/echo/response.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/vendor/github.com/labstack/echo/response.go b/vendor/github.com/labstack/echo/response.go
index 2c70d213..b23931ae 100644
--- a/vendor/github.com/labstack/echo/response.go
+++ b/vendor/github.com/labstack/echo/response.go
@@ -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