aboutsummaryrefslogtreecommitdiffhomepage
path: root/api/icon.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-04-29 16:35:04 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-04-29 16:35:04 -0700
commitf49b42f70f902d4da1e0fa4080e99164b331b716 (patch)
treec6bdd19f11d100c44b0d30344ec37038f649e988 /api/icon.go
parent1eba1730d1af50ed545f4fde78b22d6fb62ca11e (diff)
Use vanilla HTTP handlers (refactoring)
Diffstat (limited to 'api/icon.go')
-rw-r--r--api/icon.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/api/icon.go b/api/icon.go
index 7734dbf..0f5aa1b 100644
--- a/api/icon.go
+++ b/api/icon.go
@@ -6,36 +6,38 @@ package api
import (
"errors"
+ "net/http"
- "github.com/miniflux/miniflux/http/handler"
+ "github.com/miniflux/miniflux/http/context"
+ "github.com/miniflux/miniflux/http/request"
+ "github.com/miniflux/miniflux/http/response/json"
)
// FeedIcon returns a feed icon.
-func (c *Controller) FeedIcon(ctx *handler.Context, request *handler.Request, response *handler.Response) {
- userID := ctx.UserID()
- feedID, err := request.IntegerParam("feedID")
+func (c *Controller) FeedIcon(w http.ResponseWriter, r *http.Request) {
+ feedID, err := request.IntParam(r, "feedID")
if err != nil {
- response.JSON().BadRequest(err)
+ json.BadRequest(w, err)
return
}
if !c.store.HasIcon(feedID) {
- response.JSON().NotFound(errors.New("This feed doesn't have any icon"))
+ json.NotFound(w, errors.New("This feed doesn't have any icon"))
return
}
- icon, err := c.store.IconByFeedID(userID, feedID)
+ icon, err := c.store.IconByFeedID(context.New(r).UserID(), feedID)
if err != nil {
- response.JSON().ServerError(errors.New("Unable to fetch feed icon"))
+ json.ServerError(w, errors.New("Unable to fetch feed icon"))
return
}
if icon == nil {
- response.JSON().NotFound(errors.New("This feed doesn't have any icon"))
+ json.NotFound(w, errors.New("This feed doesn't have any icon"))
return
}
- response.JSON().Standard(&feedIcon{
+ json.OK(w, &feedIcon{
ID: icon.ID,
MimeType: icon.MimeType,
Data: icon.DataURL(),