summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/context.go
diff options
context:
space:
mode:
authorDuco van Amstel <helcaraxan@gmail.com>2018-11-18 17:55:05 +0000
committerWim <wim@42.be>2018-11-25 21:21:04 +0100
commit09875fe1603307080f3a4172985c5dca3bd9912d (patch)
treea23220772f6f6597d509ca71b2df3480a77b8076 /vendor/github.com/labstack/echo/context.go
parentf716b8fc0ff90f47b61e218ef34019b38bd70e0d (diff)
downloadmatterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.gz
matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.bz2
matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.zip
Update direct dependencies where possible
Diffstat (limited to 'vendor/github.com/labstack/echo/context.go')
-rw-r--r--vendor/github.com/labstack/echo/context.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/vendor/github.com/labstack/echo/context.go b/vendor/github.com/labstack/echo/context.go
index 39801f00..cf780c51 100644
--- a/vendor/github.com/labstack/echo/context.go
+++ b/vendor/github.com/labstack/echo/context.go
@@ -206,6 +206,13 @@ const (
indexPage = "index.html"
)
+func (c *context) writeContentType(value string) {
+ header := c.Response().Header()
+ if header.Get(HeaderContentType) == "" {
+ header.Set(HeaderContentType, value)
+ }
+}
+
func (c *context) Request() *http.Request {
return c.request
}
@@ -430,7 +437,7 @@ func (c *context) JSONP(code int, callback string, i interface{}) (err error) {
}
func (c *context) JSONPBlob(code int, callback string, b []byte) (err error) {
- c.response.Header().Set(HeaderContentType, MIMEApplicationJavaScriptCharsetUTF8)
+ c.writeContentType(MIMEApplicationJavaScriptCharsetUTF8)
c.response.WriteHeader(code)
if _, err = c.response.Write([]byte(callback + "(")); err != nil {
return
@@ -463,7 +470,7 @@ func (c *context) XMLPretty(code int, i interface{}, indent string) (err error)
}
func (c *context) XMLBlob(code int, b []byte) (err error) {
- c.response.Header().Set(HeaderContentType, MIMEApplicationXMLCharsetUTF8)
+ c.writeContentType(MIMEApplicationXMLCharsetUTF8)
c.response.WriteHeader(code)
if _, err = c.response.Write([]byte(xml.Header)); err != nil {
return
@@ -473,14 +480,14 @@ func (c *context) XMLBlob(code int, b []byte) (err error) {
}
func (c *context) Blob(code int, contentType string, b []byte) (err error) {
- c.response.Header().Set(HeaderContentType, contentType)
+ c.writeContentType(contentType)
c.response.WriteHeader(code)
_, err = c.response.Write(b)
return
}
func (c *context) Stream(code int, contentType string, r io.Reader) (err error) {
- c.response.Header().Set(HeaderContentType, contentType)
+ c.writeContentType(contentType)
c.response.WriteHeader(code)
_, err = io.Copy(c.response, r)
return
@@ -509,18 +516,17 @@ func (c *context) File(file string) (err error) {
return
}
-func (c *context) Attachment(file, name string) (err error) {
+func (c *context) Attachment(file, name string) error {
return c.contentDisposition(file, name, "attachment")
}
-func (c *context) Inline(file, name string) (err error) {
+func (c *context) Inline(file, name string) error {
return c.contentDisposition(file, name, "inline")
}
-func (c *context) contentDisposition(file, name, dispositionType string) (err error) {
+func (c *context) contentDisposition(file, name, dispositionType string) error {
c.response.Header().Set(HeaderContentDisposition, fmt.Sprintf("%s; filename=%q", dispositionType, name))
- c.File(file)
- return
+ return c.File(file)
}
func (c *context) NoContent(code int) error {