From eee1f3190355224eef63a4dcdef8c36eb3ca3738 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Mon, 3 Sep 2018 14:26:40 -0700 Subject: Refactor HTTP context handling --- fever/fever.go | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'fever') diff --git a/fever/fever.go b/fever/fever.go index 2f17fd2..e1090b7 100644 --- a/fever/fever.go +++ b/fever/fever.go @@ -11,7 +11,6 @@ import ( "time" "miniflux.app/config" - "miniflux.app/http/context" "miniflux.app/http/request" "miniflux.app/http/response/json" "miniflux.app/integration" @@ -180,8 +179,7 @@ is_spark equal to 1. */ func (c *Controller) handleGroups(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Fetching groups for userID=%d", userID) categories, err := c.store.Categories(userID) @@ -231,8 +229,7 @@ should be limited to feeds with an is_spark equal to 0. For the “Sparks” super group the items should be limited to feeds with an is_spark equal to 1. */ func (c *Controller) handleFeeds(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Fetching feeds for userID=%d", userID) feeds, err := c.store.Feeds(userID) @@ -285,8 +282,7 @@ A PHP/HTML example: echo ''; */ func (c *Controller) handleFavicons(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Fetching favicons for userID=%d", userID) icons, err := c.store.Icons(userID) @@ -341,8 +337,7 @@ Three optional arguments control determine the items included in the response. func (c *Controller) handleItems(w http.ResponseWriter, r *http.Request) { var result itemsResponse - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Fetching items for userID=%d", userID) builder := c.store.NewEntryQueryBuilder(userID) @@ -425,8 +420,7 @@ A request with the unread_item_ids argument will return one additional member: unread_item_ids (string/comma-separated list of positive integers) */ func (c *Controller) handleUnreadItems(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Fetching unread items for userID=%d", userID) builder := c.store.NewEntryQueryBuilder(userID) @@ -457,8 +451,7 @@ with the remote Fever installation. saved_item_ids (string/comma-separated list of positive integers) */ func (c *Controller) handleSavedItems(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Fetching saved items for userID=%d", userID) builder := c.store.NewEntryQueryBuilder(userID) @@ -486,8 +479,7 @@ func (c *Controller) handleSavedItems(w http.ResponseWriter, r *http.Request) { id=? where ? is replaced with the id of the item to modify */ func (c *Controller) handleWriteItems(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Receiving mark=item call for userID=%d", userID) entryID := request.FormInt64Value(r, "id") @@ -544,8 +536,7 @@ func (c *Controller) handleWriteItems(w http.ResponseWriter, r *http.Request) { before=? where ? is replaced with the Unix timestamp of the the local client’s most recent items API request */ func (c *Controller) handleWriteFeeds(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Receiving mark=feed call for userID=%d", userID) feedID := request.FormInt64Value(r, "id") @@ -585,8 +576,7 @@ func (c *Controller) handleWriteFeeds(w http.ResponseWriter, r *http.Request) { before=? where ? is replaced with the Unix timestamp of the the local client’s most recent items API request */ func (c *Controller) handleWriteGroups(w http.ResponseWriter, r *http.Request) { - ctx := context.New(r) - userID := ctx.UserID() + userID := request.UserID(r) logger.Debug("[Fever] Receiving mark=group call for userID=%d", userID) groupID := request.FormInt64Value(r, "id") -- cgit v1.2.3