summaryrefslogtreecommitdiff
path: root/internal/api/util/negotiate.go
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/util/negotiate.go
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/util/negotiate.go')
-rw-r--r--internal/api/util/negotiate.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/api/util/negotiate.go b/internal/api/util/negotiate.go
index f4268511b..5b4f54bc6 100644
--- a/internal/api/util/negotiate.go
+++ b/internal/api/util/negotiate.go
@@ -26,7 +26,7 @@ import (
)
// JSONAcceptHeaders is a slice of offers that just contains application/json types.
-var JSONAcceptHeaders = []MIME{
+var JSONAcceptHeaders = []string{
AppJSON,
}
@@ -34,7 +34,7 @@ var JSONAcceptHeaders = []MIME{
// jrd+json content type, but will be chill and fall back to app/json.
// This is to be used specifically for webfinger responses.
// See https://www.rfc-editor.org/rfc/rfc7033#section-10.2
-var WebfingerJSONAcceptHeaders = []MIME{
+var WebfingerJSONAcceptHeaders = []string{
AppJRDJSON,
AppJSON,
}
@@ -42,13 +42,13 @@ var WebfingerJSONAcceptHeaders = []MIME{
// JSONOrHTMLAcceptHeaders is a slice of offers that prefers AppJSON and will
// fall back to HTML if necessary. This is useful for error handling, since it can
// be used to serve a nice HTML page if the caller accepts that, or just JSON if not.
-var JSONOrHTMLAcceptHeaders = []MIME{
+var JSONOrHTMLAcceptHeaders = []string{
AppJSON,
TextHTML,
}
// HTMLAcceptHeaders is a slice of offers that just contains text/html types.
-var HTMLAcceptHeaders = []MIME{
+var HTMLAcceptHeaders = []string{
TextHTML,
}
@@ -57,7 +57,7 @@ var HTMLAcceptHeaders = []MIME{
// but which should also be able to serve ActivityPub as a fallback.
//
// https://www.w3.org/TR/activitypub/#retrieving-objects
-var HTMLOrActivityPubHeaders = []MIME{
+var HTMLOrActivityPubHeaders = []string{
TextHTML,
AppActivityLDJSON,
AppActivityJSON,
@@ -68,7 +68,7 @@ var HTMLOrActivityPubHeaders = []MIME{
// which a user might also go to in their browser sometimes.
//
// https://www.w3.org/TR/activitypub/#retrieving-objects
-var ActivityPubOrHTMLHeaders = []MIME{
+var ActivityPubOrHTMLHeaders = []string{
AppActivityLDJSON,
AppActivityJSON,
TextHTML,
@@ -78,12 +78,12 @@ var ActivityPubOrHTMLHeaders = []MIME{
// This is useful for URLs should only serve ActivityPub.
//
// https://www.w3.org/TR/activitypub/#retrieving-objects
-var ActivityPubHeaders = []MIME{
+var ActivityPubHeaders = []string{
AppActivityLDJSON,
AppActivityJSON,
}
-var HostMetaHeaders = []MIME{
+var HostMetaHeaders = []string{
AppXMLXRD,
AppXML,
}
@@ -109,7 +109,7 @@ var HostMetaHeaders = []MIME{
// often-used Accept types.
//
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation#server-driven_content_negotiation
-func NegotiateAccept(c *gin.Context, offers ...MIME) (string, error) {
+func NegotiateAccept(c *gin.Context, offers ...string) (string, error) {
if len(offers) == 0 {
return "", errors.New("no format offered")
}