aboutsummaryrefslogtreecommitdiff
path: root/internal/api/icon.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <f@miniflux.net> 2023-10-05 22:23:29 -0700
committerGravatar Frédéric Guillot <f@miniflux.net> 2023-10-06 13:52:33 -0700
commit2002d60fbe0cbc0b74bfcc29305d018db1564d3c (patch)
treee51d3b24697dadc2fb96e45556ba9b5666a16d35 /internal/api/icon.go
parent5774323f2ef646bea3e078a8bee382ea45a7e276 (diff)
downloadv2-2002d60fbe0cbc0b74bfcc29305d018db1564d3c.tar.gz
v2-2002d60fbe0cbc0b74bfcc29305d018db1564d3c.tar.zst
v2-2002d60fbe0cbc0b74bfcc29305d018db1564d3c.zip
Add new API endpoint /icons/{iconID}
Diffstat (limited to 'internal/api/icon.go')
-rw-r--r--internal/api/icon.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/internal/api/icon.go b/internal/api/icon.go
index 11cbbfa6..84db8652 100644
--- a/internal/api/icon.go
+++ b/internal/api/icon.go
@@ -10,7 +10,7 @@ import (
"miniflux.app/v2/internal/http/response/json"
)
-func (h *handler) feedIcon(w http.ResponseWriter, r *http.Request) {
+func (h *handler) getIconByFeedID(w http.ResponseWriter, r *http.Request) {
feedID := request.RouteInt64Param(r, "feedID")
if !h.store.HasIcon(feedID) {
@@ -35,3 +35,24 @@ func (h *handler) feedIcon(w http.ResponseWriter, r *http.Request) {
Data: icon.DataURL(),
})
}
+
+func (h *handler) getIconByIconID(w http.ResponseWriter, r *http.Request) {
+ iconID := request.RouteInt64Param(r, "iconID")
+
+ icon, err := h.store.IconByID(iconID)
+ if err != nil {
+ json.ServerError(w, r, err)
+ return
+ }
+
+ if icon == nil {
+ json.NotFound(w, r)
+ return
+ }
+
+ json.OK(w, r, &feedIconResponse{
+ ID: icon.ID,
+ MimeType: icon.MimeType,
+ Data: icon.DataURL(),
+ })
+}