mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
feat: combine feed icon handlers to use only externalIconID
This commit is contained in:
parent
c531be8780
commit
c75e0ceea1
16 changed files with 33 additions and 52 deletions
|
@ -12,9 +12,9 @@ import (
|
|||
"miniflux.app/v2/internal/http/response/html"
|
||||
)
|
||||
|
||||
func (h *handler) showIcon(w http.ResponseWriter, r *http.Request) {
|
||||
iconID := request.RouteInt64Param(r, "iconID")
|
||||
icon, err := h.store.IconByID(iconID)
|
||||
func (h *handler) showFeedIcon(w http.ResponseWriter, r *http.Request) {
|
||||
externalIconID := request.RouteStringParam(r, "externalIconID")
|
||||
icon, err := h.store.IconByExternalID(externalIconID)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
|
|
|
@ -63,6 +63,13 @@ func (m *middleware) handleUserSession(next http.Handler) http.Handler {
|
|||
|
||||
func (m *middleware) handleAppSession(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if mux.CurrentRoute(r).GetName() == "feedIcon" {
|
||||
// Skip app session handling for the feed icon route to avoid unnecessary session creation
|
||||
// when fetching feed icons.
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
session := m.getAppSessionValueFromCookie(r)
|
||||
|
||||
|
@ -154,6 +161,7 @@ func (m *middleware) isPublicRoute(r *http.Request) bool {
|
|||
"oauth2Redirect",
|
||||
"oauth2Callback",
|
||||
"appIcon",
|
||||
"feedIcon",
|
||||
"favicon",
|
||||
"webManifest",
|
||||
"robots",
|
||||
|
|
|
@ -74,7 +74,7 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool) {
|
|||
uiRouter.HandleFunc("/feed/{feedID}/entries/all", handler.showFeedEntriesAllPage).Name("feedEntriesAll").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/feed/{feedID}/entry/{entryID}", handler.showFeedEntryPage).Name("feedEntry").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/unread/feed/{feedID}/entry/{entryID}", handler.showUnreadFeedEntryPage).Name("unreadFeedEntry").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/feed/icon/{iconID}", handler.showIcon).Name("icon").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/feed/icon/{externalIconID}", handler.showFeedIcon).Name("feedIcon").Methods(http.MethodGet)
|
||||
uiRouter.HandleFunc("/feed/{feedID}/mark-all-as-read", handler.markFeedAsRead).Name("markFeedAsRead").Methods(http.MethodPost)
|
||||
|
||||
// Category pages.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue