Add /v4/image api (#8230)
* add image api * i suppose i should add a test... * only redirect to image proxy
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
e7b084842a
Коммит
0daac7e4fc
22
api4/image.go
Обычный файл
22
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)
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user