aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/api/controller/feed.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/api/controller/feed.go')
-rw-r--r--server/api/controller/feed.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/server/api/controller/feed.go b/server/api/controller/feed.go
index c9dc9e2..8ec0e04 100644
--- a/server/api/controller/feed.go
+++ b/server/api/controller/feed.go
@@ -15,17 +15,17 @@ func (c *Controller) CreateFeed(ctx *core.Context, request *core.Request, respon
userID := ctx.GetUserID()
feedURL, categoryID, err := payload.DecodeFeedCreationPayload(request.Body())
if err != nil {
- response.Json().BadRequest(err)
+ response.JSON().BadRequest(err)
return
}
feed, err := c.feedHandler.CreateFeed(userID, categoryID, feedURL)
if err != nil {
- response.Json().ServerError(errors.New("Unable to create this feed"))
+ response.JSON().ServerError(errors.New("Unable to create this feed"))
return
}
- response.Json().Created(feed)
+ response.JSON().Created(feed)
}
// RefreshFeed is the API handler to refresh a feed.
@@ -33,17 +33,17 @@ func (c *Controller) RefreshFeed(ctx *core.Context, request *core.Request, respo
userID := ctx.GetUserID()
feedID, err := request.IntegerParam("feedID")
if err != nil {
- response.Json().BadRequest(err)
+ response.JSON().BadRequest(err)
return
}
err = c.feedHandler.RefreshFeed(userID, feedID)
if err != nil {
- response.Json().ServerError(errors.New("Unable to refresh this feed"))
+ response.JSON().ServerError(errors.New("Unable to refresh this feed"))
return
}
- response.Json().NoContent()
+ response.JSON().NoContent()
}
// UpdateFeed is the API handler that is used to update a feed.
@@ -51,45 +51,45 @@ func (c *Controller) UpdateFeed(ctx *core.Context, request *core.Request, respon
userID := ctx.GetUserID()
feedID, err := request.IntegerParam("feedID")
if err != nil {
- response.Json().BadRequest(err)
+ response.JSON().BadRequest(err)
return
}
newFeed, err := payload.DecodeFeedModificationPayload(request.Body())
if err != nil {
- response.Json().BadRequest(err)
+ response.JSON().BadRequest(err)
return
}
originalFeed, err := c.store.GetFeedById(userID, feedID)
if err != nil {
- response.Json().NotFound(errors.New("Unable to find this feed"))
+ response.JSON().NotFound(errors.New("Unable to find this feed"))
return
}
if originalFeed == nil {
- response.Json().NotFound(errors.New("Feed not found"))
+ response.JSON().NotFound(errors.New("Feed not found"))
return
}
originalFeed.Merge(newFeed)
if err := c.store.UpdateFeed(originalFeed); err != nil {
- response.Json().ServerError(errors.New("Unable to update this feed"))
+ response.JSON().ServerError(errors.New("Unable to update this feed"))
return
}
- response.Json().Created(originalFeed)
+ response.JSON().Created(originalFeed)
}
// GetFeeds is the API handler that get all feeds that belongs to the given user.
func (c *Controller) GetFeeds(ctx *core.Context, request *core.Request, response *core.Response) {
feeds, err := c.store.GetFeeds(ctx.GetUserID())
if err != nil {
- response.Json().ServerError(errors.New("Unable to fetch feeds from the database"))
+ response.JSON().ServerError(errors.New("Unable to fetch feeds from the database"))
return
}
- response.Json().Standard(feeds)
+ response.JSON().Standard(feeds)
}
// GetFeed is the API handler to get a feed.
@@ -97,22 +97,22 @@ func (c *Controller) GetFeed(ctx *core.Context, request *core.Request, response
userID := ctx.GetUserID()
feedID, err := request.IntegerParam("feedID")
if err != nil {
- response.Json().BadRequest(err)
+ response.JSON().BadRequest(err)
return
}
feed, err := c.store.GetFeedById(userID, feedID)
if err != nil {
- response.Json().ServerError(errors.New("Unable to fetch this feed"))
+ response.JSON().ServerError(errors.New("Unable to fetch this feed"))
return
}
if feed == nil {
- response.Json().NotFound(errors.New("Feed not found"))
+ response.JSON().NotFound(errors.New("Feed not found"))
return
}
- response.Json().Standard(feed)
+ response.JSON().Standard(feed)
}
// RemoveFeed is the API handler to remove a feed.
@@ -120,19 +120,19 @@ func (c *Controller) RemoveFeed(ctx *core.Context, request *core.Request, respon
userID := ctx.GetUserID()
feedID, err := request.IntegerParam("feedID")
if err != nil {
- response.Json().BadRequest(err)
+ response.JSON().BadRequest(err)
return
}
if !c.store.FeedExists(userID, feedID) {
- response.Json().NotFound(errors.New("Feed not found"))
+ response.JSON().NotFound(errors.New("Feed not found"))
return
}
if err := c.store.RemoveFeed(userID, feedID); err != nil {
- response.Json().ServerError(errors.New("Unable to remove this feed"))
+ response.JSON().ServerError(errors.New("Unable to remove this feed"))
return
}
- response.Json().NoContent()
+ response.JSON().NoContent()
}