github.com/xzl8028/xenia-server@v0.0.0-20190809101854-18450a97da63/api4/image.go (about) 1 // Copyright (c) 2017-present Xenia, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package api4 5 6 import ( 7 "net/http" 8 ) 9 10 func (api *API) InitImage() { 11 api.BaseRoutes.Image.Handle("", api.ApiSessionRequiredTrustRequester(getImage)).Methods("GET") 12 } 13 14 func getImage(c *Context, w http.ResponseWriter, r *http.Request) { 15 url := r.URL.Query().Get("url") 16 17 if *c.App.Config().ImageProxySettings.Enable { 18 c.App.ImageProxy.GetImage(w, r, url) 19 } else { 20 http.Redirect(w, r, url, http.StatusFound) 21 } 22 }