1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Improve request package and add more unit tests

This commit is contained in:
Frédéric Guillot 2018-09-23 21:02:26 -07:00
parent 844680e573
commit 9d08139f43
49 changed files with 916 additions and 400 deletions

View file

@ -43,11 +43,7 @@ func (c *Controller) CreateCategory(w http.ResponseWriter, r *http.Request) {
// UpdateCategory is the API handler to update a category.
func (c *Controller) UpdateCategory(w http.ResponseWriter, r *http.Request) {
categoryID, err := request.IntParam(r, "categoryID")
if err != nil {
json.BadRequest(w, err)
return
}
categoryID := request.RouteInt64Param(r, "categoryID")
category, err := decodeCategoryPayload(r.Body)
if err != nil {
@ -85,11 +81,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) {
userID := request.UserID(r)
categoryID, err := request.IntParam(r, "categoryID")
if err != nil {
json.BadRequest(w, err)
return
}
categoryID := request.RouteInt64Param(r, "categoryID")
if !c.store.CategoryExists(userID, categoryID) {
json.NotFound(w, errors.New("Category not found"))