Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultLanguage = []language.Tag{ language.AmericanEnglish, language.English, }
DefaultLanguage is the default language applied by default.
var HTTPClient contextKey
HTTPClient is the context key used to specify the HTTP client used to issue the request.
Functions ¶
func Apply ¶
func Apply(req *http.Request, opts []RequestOption) error
Apply applies the given RequestOptions to the request in order. Caller-provided opts take precedence over any defaults appended after them. For example, append caller opts before defaults like append(opts, internal.DefaultLanguage) so that the caller's preferences are evaluated first.
func ContextClient ¶
ContextClient returns an HTTP client based on the given context.Context.
Types ¶
type Error ¶
type Error struct {
// StatusCode is the HTTP status code of the response, e.g. 404.
StatusCode int `json:"code,omitempty"`
// Type indicates the type of the Error.
Type string `json:"error,omitempty"`
// Code is the numerical error code for the Error.
Code int `json:"errorCode,omitempty"`
// Details encapsulates custom data specific to the Error.
Details map[string][]string `json:"errorDetails,omitempty"`
// Message optionally contains a human-readable message describing the Error.
Message string `json:"errorMessage,omitempty"`
// Status is the HTTP status of the response, e.g. Not Found.
Status string `json:"status,omitempty"`
}
Error represents an error included in the response body.
type RequestOption ¶
RequestOption specifies an option to be applied to an outgoing HTTP request.
Callers may accept multiple RequestOptions as a variadic or slice parameter. Options must be applied to the request using Apply.
A RequestOption must be reusable and must not hold any per-request state.
func AcceptLanguage ¶
func AcceptLanguage(tags []language.Tag) RequestOption
AcceptLanguage returns a internal.RequestOption that appends the given language tags to the 'Accept-Language' header on outgoing requests, preserving any tags already present in the header.
func RequestHeader ¶
func RequestHeader(key, value string) RequestOption
RequestHeader returns a internal.RequestOption that sets a request header with the given name and value on outgoing requests.
type Result ¶
type Result[T any] struct { // StatusCode is the HTTP status code of the response, e.g. 200. StatusCode int `json:"code,omitempty"` // Data is the payload of the Result. Data T `json:"data,omitempty"` // Status is the HTTP status of the response, e.g. OK. Status string `json:"status,omitempty"` }
Result represents a successful response in PlayFab API. Make sure to specify the T generic type to whatever you want in the Data.