aboutsummaryrefslogtreecommitdiffhomepage
path: root/api/category.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-09-03 14:26:40 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-09-03 14:26:40 -0700
commiteee1f3190355224eef63a4dcdef8c36eb3ca3738 (patch)
tree009b7ca67b96d9be473d8ddf2c8c95f22a6749d1 /api/category.go
parent88e81d4d800ff6433518522954197d75203a25c2 (diff)
Refactor HTTP context handling
Diffstat (limited to 'api/category.go')
-rw-r--r--api/category.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/api/category.go b/api/category.go
index 5a57865..e74aa3b 100644
--- a/api/category.go
+++ b/api/category.go
@@ -8,7 +8,6 @@ import (
"errors"
"net/http"
- "miniflux.app/http/context"
"miniflux.app/http/request"
"miniflux.app/http/response/json"
)
@@ -21,8 +20,7 @@ func (c *Controller) CreateCategory(w http.ResponseWriter, r *http.Request) {
return
}
- ctx := context.New(r)
- userID := ctx.UserID()
+ userID := request.UserID(r)
category.UserID = userID
if err := category.ValidateCategoryCreation(); err != nil {
json.BadRequest(w, err)
@@ -57,8 +55,7 @@ func (c *Controller) UpdateCategory(w http.ResponseWriter, r *http.Request) {
return
}
- ctx := context.New(r)
- category.UserID = ctx.UserID()
+ category.UserID = request.UserID(r)
category.ID = categoryID
if err := category.ValidateCategoryModification(); err != nil {
json.BadRequest(w, err)
@@ -76,8 +73,7 @@ func (c *Controller) UpdateCategory(w http.ResponseWriter, r *http.Request) {
// GetCategories is the API handler to get a list of categories for a given user.
func (c *Controller) GetCategories(w http.ResponseWriter, r *http.Request) {
- ctx := context.New(r)
- categories, err := c.store.Categories(ctx.UserID())
+ categories, err := c.store.Categories(request.UserID(r))
if err != nil {
json.ServerError(w, err)
return
@@ -88,8 +84,7 @@ func (c *Controller) GetCategories(w http.ResponseWriter, r *http.Request) {
// RemoveCategory is the API handler to remove a category.
func (c *Controller) RemoveCategory(w http.ResponseWriter, r *http.Request) {
- ctx := context.New(r)
- userID := ctx.UserID()
+ userID := request.UserID(r)
categoryID, err := request.IntParam(r, "categoryID")
if err != nil {
json.BadRequest(w, err)