diff options
author | Chris <ccbrown112@gmail.com> | 2018-02-09 13:56:11 -0600 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2018-02-09 11:56:11 -0800 |
commit | 0daac7e4fc05ecb64dbc162daff618569bb249cd (patch) | |
tree | cf2a5145c750aa1781d317681f2a1d3e28249739 /api4/image.go | |
parent | e7b084842a4d371ac3ac1feab952d19524e607d3 (diff) | |
download | chat-0daac7e4fc05ecb64dbc162daff618569bb249cd.tar.gz chat-0daac7e4fc05ecb64dbc162daff618569bb249cd.tar.bz2 chat-0daac7e4fc05ecb64dbc162daff618569bb249cd.zip |
Add /v4/image api (#8230)
* add image api
* i suppose i should add a test...
* only redirect to image proxy
Diffstat (limited to 'api4/image.go')
-rw-r--r-- | api4/image.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/api4/image.go b/api4/image.go new file mode 100644 index 000000000..4589de204 --- /dev/null +++ b/api4/image.go @@ -0,0 +1,22 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package api4 + +import ( + "net/http" +) + +func (api *API) InitImage() { + api.BaseRoutes.Image.Handle("", api.ApiSessionRequiredTrustRequester(getImage)).Methods("GET") +} + +func getImage(c *Context, w http.ResponseWriter, r *http.Request) { + // Only redirect to our image proxy if one is enabled. Arbitrary redirects are not allowed for + // security reasons. + if transform := c.App.ImageProxyAdder(); transform != nil { + http.Redirect(w, r, transform(r.URL.Query().Get("url")), http.StatusFound) + } else { + http.NotFound(w, r) + } +} |