diff options
author | 2023-11-27 14:00:57 +0000 | |
---|---|---|
committer | 2023-11-27 14:00:57 +0000 | |
commit | 74700cc8034980334e7df466f313287a41d2b8a6 (patch) | |
tree | 63ab8912c813eefba8a492e0d0489f4e5fe59446 /internal/api/activitypub/users/repliesget.go | |
parent | [chore]: Bump codeberg.org/gruf/go-mutexes from 1.3.0 to 1.3.1 (#2387) (diff) | |
download | gotosocial-74700cc8034980334e7df466f313287a41d2b8a6.tar.xz |
[performance] http response encoding / writing improvements (#2374)
Diffstat (limited to 'internal/api/activitypub/users/repliesget.go')
-rw-r--r-- | internal/api/activitypub/users/repliesget.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/internal/api/activitypub/users/repliesget.go b/internal/api/activitypub/users/repliesget.go index 3ac4ccbbb..2d3472f35 100644 --- a/internal/api/activitypub/users/repliesget.go +++ b/internal/api/activitypub/users/repliesget.go @@ -18,7 +18,6 @@ package users import ( - "encoding/json" "errors" "net/http" "strings" @@ -107,13 +106,13 @@ func (m *Module) StatusRepliesGETHandler(c *gin.Context) { return } - format, err := apiutil.NegotiateAccept(c, apiutil.ActivityPubOrHTMLHeaders...) + contentType, err := apiutil.NegotiateAccept(c, apiutil.ActivityPubOrHTMLHeaders...) if err != nil { apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1) return } - if format == string(apiutil.TextHTML) { + if contentType == string(apiutil.TextHTML) { // redirect to the status c.Redirect(http.StatusSeeOther, "/@"+requestedUsername+"/statuses/"+requestedStatusID) return @@ -161,12 +160,5 @@ func (m *Module) StatusRepliesGETHandler(c *gin.Context) { return } - b, err := json.Marshal(resp) - if err != nil { - errWithCode := gtserror.NewErrorInternalError(err) - apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) - return - } - - c.Data(http.StatusOK, format, b) + apiutil.JSONType(c, http.StatusOK, contentType, resp) } |