summaryrefslogtreecommitdiff
path: root/internal/api/util/negotiate.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-07-13 21:27:25 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-13 21:27:25 +0200
commit12b6cdcd8ce52269be5a1ca8acaae006896808b5 (patch)
treeeba84aa522ba2ccbfb539930789a046630d03dae /internal/api/util/negotiate.go
parent[chore] Skip webfinger test on CI (#1983) (diff)
downloadgotosocial-12b6cdcd8ce52269be5a1ca8acaae006896808b5.tar.xz
[bugfix] Set Vary header correctly on cache-control (#1988)v0.10.0-rc2
* [bugfix] Set Vary header correctly on cache-control * Prefer activitypub types on AP endpoints * use immutable on file server, vary by range * vary auth on Accept
Diffstat (limited to 'internal/api/util/negotiate.go')
-rw-r--r--internal/api/util/negotiate.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/internal/api/util/negotiate.go b/internal/api/util/negotiate.go
index 6d68a0df3..f4268511b 100644
--- a/internal/api/util/negotiate.go
+++ b/internal/api/util/negotiate.go
@@ -25,12 +25,6 @@ import (
"github.com/gin-gonic/gin"
)
-// ActivityPubAcceptHeaders represents the Accept headers mentioned here:
-var ActivityPubAcceptHeaders = []MIME{
- AppActivityJSON,
- AppActivityLDJSON,
-}
-
// JSONAcceptHeaders is a slice of offers that just contains application/json types.
var JSONAcceptHeaders = []MIME{
AppJSON,
@@ -59,12 +53,34 @@ var HTMLAcceptHeaders = []MIME{
}
// HTMLOrActivityPubHeaders matches text/html first, then activitypub types.
-// This is useful for user URLs that a user might go to in their browser.
+// This is useful for user URLs that a user might go to in their browser,
+// but which should also be able to serve ActivityPub as a fallback.
+//
// https://www.w3.org/TR/activitypub/#retrieving-objects
var HTMLOrActivityPubHeaders = []MIME{
TextHTML,
+ AppActivityLDJSON,
+ AppActivityJSON,
+}
+
+// ActivityPubOrHTMLHeaders matches activitypub types first, then text/html.
+// This is useful for URLs that should serve ActivityPub by default, but
+// which a user might also go to in their browser sometimes.
+//
+// https://www.w3.org/TR/activitypub/#retrieving-objects
+var ActivityPubOrHTMLHeaders = []MIME{
+ AppActivityLDJSON,
AppActivityJSON,
+ TextHTML,
+}
+
+// ActivityPubHeaders matches only activitypub Accept headers.
+// This is useful for URLs should only serve ActivityPub.
+//
+// https://www.w3.org/TR/activitypub/#retrieving-objects
+var ActivityPubHeaders = []MIME{
AppActivityLDJSON,
+ AppActivityJSON,
}
var HostMetaHeaders = []MIME{