1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

Improve Response to be more idiomatic

This commit is contained in:
Frédéric Guillot 2017-11-21 18:30:16 -08:00
parent 25cbd65777
commit 02ff7b4bcf
25 changed files with 302 additions and 275 deletions

View file

@ -18,26 +18,26 @@ import (
func (c *Controller) ImageProxy(ctx *core.Context, request *core.Request, response *core.Response) {
encodedURL := request.StringParam("encodedURL", "")
if encodedURL == "" {
response.Html().BadRequest(errors.New("No URL provided"))
response.HTML().BadRequest(errors.New("No URL provided"))
return
}
decodedURL, err := base64.StdEncoding.DecodeString(encodedURL)
if err != nil {
response.Html().BadRequest(errors.New("Unable to decode this URL"))
response.HTML().BadRequest(errors.New("Unable to decode this URL"))
return
}
resp, err := http.Get(string(decodedURL))
if err != nil {
log.Println(err)
response.Html().NotFound()
response.HTML().NotFound()
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
response.Html().NotFound()
response.HTML().NotFound()
return
}