reactive

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

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

https://tools.ietf.org/html/rfc7231#section-3.4.2

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL