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/statusget.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/statusget.go')
| -rw-r--r-- | internal/api/activitypub/users/statusget.go | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/internal/api/activitypub/users/statusget.go b/internal/api/activitypub/users/statusget.go index f7b5ccfd1..27af9c6b4 100644 --- a/internal/api/activitypub/users/statusget.go +++ b/internal/api/activitypub/users/statusget.go @@ -18,7 +18,6 @@ package users import ( - "encoding/json" "errors" "net/http" "strings" @@ -46,13 +45,13 @@ func (m *Module) StatusGETHandler(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 @@ -64,11 +63,5 @@ func (m *Module) StatusGETHandler(c *gin.Context) { return } - b, err := json.Marshal(resp) - if err != nil { - apiutil.ErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGetV1) - return - } - - c.Data(http.StatusOK, format, b) + apiutil.JSONType(c, http.StatusOK, contentType, resp) } |
