Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ActivityPubAcceptHeaders = []Offer{ AppActivityJSON, AppActivityLDJSON, }
ActivityPubAcceptHeaders represents the Accept headers mentioned here: https://www.w3.org/TR/activitypub/#retrieving-objects
var HTMLAcceptHeaders = []Offer{ TextHTML, }
HTMLAcceptHeaders is a slice of offers that just contains text/html types.
var JSONAcceptHeaders = []Offer{ AppJSON, }
JSONAcceptHeaders is a slice of offers that just contains application/json types.
Functions ¶
func NegotiateAccept ¶ added in v0.2.0
NegotiateAccept takes the *gin.Context from an incoming request, and a slice of Offers, and performs content negotiation for the given request with the given content-type offers. It will return a string representation of the first suitable content-type, or an error if something goes wrong or a suitable content-type cannot be matched.
For example, if the request in the *gin.Context has Accept headers of value [application/json, text/html], and the provided offers are of value [application/json, application/xml], then the returned string will be 'application/json', which indicates the content-type that should be returned.
If the length of offers is 0, then an error will be returned, so this function should only be called in places where format negotiation is actually needed.
If there are no Accept headers in the request, then the first offer will be returned, under the assumption that it's better to serve *something* than error out completely.
Callers can use the offer slices exported in this package as shortcuts for often-used Accept types.
Types ¶
type ClientModule ¶
ClientModule represents a chunk of code (usually contained in a single package) that adds a set of functionalities and/or side effects to a router, by mapping routes and/or middlewares onto it--in other words, a REST API ;) A ClientAPIMpdule with routes corresponds roughly to one main path of the gotosocial REST api, for example /api/v1/accounts/ or /oauth/
type FederationModule ¶
FederationModule represents a chunk of code (usually contained in a single package) that adds a set of functionalities and/or side effects to a router, by mapping routes and/or middlewares onto it--in other words, a REST API ;) Unlike ClientAPIModule, federation API module is not intended to be interacted with by clients directly -- it is primarily a server-to-server interface.
type Offer ¶ added in v0.2.0
type Offer string
Offer represents an offered mime-type.
const ( AppJSON Offer = `application/json` // AppJSON is the mime type for 'application/json'. AppActivityJSON Offer = `application/activity+json` // AppActivityJSON is the mime type for 'application/activity+json'. AppActivityLDJSON Offer = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"` // AppActivityLDJSON is the mime type for 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' TextHTML Offer = `text/html` // TextHTML is the mime type for 'text/html'. )