summaryrefslogtreecommitdiff
path: root/internal/api/activitypub/emoji
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-11-27 14:00:57 +0000
committerLibravatar GitHub <noreply@github.com>2023-11-27 14:00:57 +0000
commit74700cc8034980334e7df466f313287a41d2b8a6 (patch)
tree63ab8912c813eefba8a492e0d0489f4e5fe59446 /internal/api/activitypub/emoji
parent[chore]: Bump codeberg.org/gruf/go-mutexes from 1.3.0 to 1.3.1 (#2387) (diff)
downloadgotosocial-74700cc8034980334e7df466f313287a41d2b8a6.tar.xz
[performance] http response encoding / writing improvements (#2374)
Diffstat (limited to 'internal/api/activitypub/emoji')
-rw-r--r--internal/api/activitypub/emoji/emojiget.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/api/activitypub/emoji/emojiget.go b/internal/api/activitypub/emoji/emojiget.go
index c291a500a..5a9f0db72 100644
--- a/internal/api/activitypub/emoji/emojiget.go
+++ b/internal/api/activitypub/emoji/emojiget.go
@@ -18,7 +18,6 @@
package emoji
import (
- "encoding/json"
"errors"
"net/http"
"strings"
@@ -36,7 +35,7 @@ func (m *Module) EmojiGetHandler(c *gin.Context) {
return
}
- format, err := apiutil.NegotiateAccept(c, apiutil.ActivityPubHeaders...)
+ contentType, err := apiutil.NegotiateAccept(c, apiutil.ActivityPubHeaders...)
if err != nil {
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
return
@@ -48,11 +47,12 @@ func (m *Module) EmojiGetHandler(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)
+ // Encode JSON HTTP response.
+ apiutil.EncodeJSONResponse(
+ c.Writer,
+ c.Request,
+ http.StatusOK,
+ contentType,
+ resp,
+ )
}