diff options
author | 2023-05-12 08:16:41 +0000 | |
---|---|---|
committer | 2023-05-12 10:16:41 +0200 | |
commit | ba5a464ca5d3fcbd171c174a4f07c3326ecb01df (patch) | |
tree | 4289873a2fef9a9b102fb692b0cf6d3409a41747 /internal/web/rss.go | |
parent | use more semantic headers for profile page (#1765) (diff) | |
download | gotosocial-ba5a464ca5d3fcbd171c174a4f07c3326ecb01df.tar.xz |
[chore] Prefer JSON errors in API endpoints (#1766)
* Default to JSON over HTML for error handling
* Change the default error display for web endpoints to html
Diffstat (limited to 'internal/web/rss.go')
-rw-r--r-- | internal/web/rss.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/web/rss.go b/internal/web/rss.go index fc7923213..8c8d5112f 100644 --- a/internal/web/rss.go +++ b/internal/web/rss.go @@ -83,7 +83,7 @@ func (m *Module) rssFeedGETHandler(c *gin.Context) { ctx := c.Request.Context() if _, err := apiutil.NegotiateAccept(c, apiutil.AppRSSXML); err != nil { - apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1) + apiutil.WebErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1) return } @@ -91,7 +91,7 @@ func (m *Module) rssFeedGETHandler(c *gin.Context) { username := strings.ToLower(c.Param(usernameKey)) if username == "" { err := errors.New("no account username specified") - apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1) + apiutil.WebErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1) return } @@ -100,7 +100,7 @@ func (m *Module) rssFeedGETHandler(c *gin.Context) { getRssFeed, accountLastPostedPublic, errWithCode := m.processor.Account().GetRSSFeedForUsername(ctx, username) if errWithCode != nil { - apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) + apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return } @@ -112,13 +112,13 @@ func (m *Module) rssFeedGETHandler(c *gin.Context) { // we either have no cache entry for this, or we have an expired cache entry; generate a new one rssFeed, errWithCode = getRssFeed() if errWithCode != nil { - apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) + apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return } eTag, err := generateEtag(bytes.NewBufferString(rssFeed)) if err != nil { - apiutil.ErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGetV1) + apiutil.WebErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGetV1) return } @@ -146,7 +146,7 @@ func (m *Module) rssFeedGETHandler(c *gin.Context) { // we had a cache entry already so we didn't call to get the rss feed yet rssFeed, errWithCode = getRssFeed() if errWithCode != nil { - apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) + apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return } } |