Documentation ¶
Overview ¶
Package reactive implements reactive content negotiation as defined in RFC7231 Section 3.4.2.
Construction ¶
For out of the box reactive negotiation support, use reactive.Default, which is the default reactive negotiator.
//retrieves the default reactive negotiator. p := reactive.Default
In situations where more customization is required, use the reactive.New constructor function and specify options as arguments.
// constructs a reactive negotiator with the provided options. p := reactive.New( reactive.Logger(l), )
See Also ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Representation defines representation to utilize when returning // responses to user agents engaging in reactive negotiation. Representation = func(constructor representation.ListConstructor) Option { return func(o *Options) { o.RepresentationConstructor = constructor } } // Logger specifies the logger for the reactive negotiator. Logger = func(l *zap.Logger) Option { return func(o *Options) { o.Logger = l } } // Scope specifies the metric scope to leverage for the reactive // negotiator. Scope = func(s tally.Scope) Option { return func(o *Options) { o.Scope = s } } )
Options that can be used to configure and extend reactive negotiators.
var ( // Default is the default reactive negotiator. Default = New() )
Defines the default reactive negotiator.
The default configuration is as follows:
➣ The representation for 406 Not Acceptable responses utilizes the JSON (application/json) media type.
Functions ¶
This section is empty.
Types ¶
type Negotiator ¶
type Negotiator struct {
// contains filtered or unexported fields
}
Negotiator represents the negotiator responsible for performing reactive (agent-driven) negotiation.
func New ¶
func New(options ...Option) Negotiator
New constructs a negotiator capable of performing reactive (agent-driven) negotiation with the options provided.
func (Negotiator) Negotiate ¶
func (n Negotiator) Negotiate( ctx negotiator.NegotiationContext, reps ...representation.Representation) (err error)
Negotiate performs reactive (agent-driven) content negotiation with the representations provided.
type Option ¶
type Option = func(*Options)
Option represents a configurable option for reactive (agent-driven) content negotiation.
type Options ¶
type Options struct { RepresentationConstructor representation.ListConstructor Logger *zap.Logger Scope tally.Scope }
Options represents the configuration options for reactive (agent-driven) content negotiation.