Documentation ¶
Overview ¶
Package maniphttp provides a ReST backed Manipulator.
This is meant to be use to communicate with Bahamut based API servers.
Index ¶
- func ExtractCredentials(manipulator manipulate.Manipulator) (string, string)
- func ExtractEncoding(manipulator manipulate.Manipulator) elemental.EncodingType
- func ExtractEndpoint(manipulator manipulate.Manipulator) string
- func ExtractNamespace(manipulator manipulate.Manipulator) string
- func ExtractTLSConfig(manipulator manipulate.Manipulator) *tls.Config
- func New(ctx context.Context, url string, options ...Option) (manipulate.Manipulator, error)
- func NewHTTPManipulator(url, username, password, namespace string) manipulate.Manipulator
- func NewHTTPManipulatorWithTLS(url, username, password, namespace string, tlsConfig *tls.Config) manipulate.Manipulator
- func NewHTTPManipulatorWithTokenManager(ctx context.Context, url string, namespace string, tlsConfig *tls.Config, ...) (manipulate.Manipulator, error)
- func NewSubscriber(manipulator manipulate.Manipulator, options ...SubscriberOption) manipulate.Subscriber
- func NewSubscriberWithEndpoint(manipulator manipulate.Manipulator, endpoint string, recursive bool) manipulate.Subscriber
- func SetGlobalHeaders(manipulator manipulate.Manipulator, headers http.Header)
- type Option
- func OptionAdditonalHeaders(headers http.Header) Option
- func OptionCredentials(username, password string) Option
- func OptionDisableBuiltInRetry() Option
- func OptionEncoding(enc elemental.EncodingType) Option
- func OptionHTTPClient(client *http.Client) Option
- func OptionHTTPTransport(transport *http.Transport) Option
- func OptionNamespace(ns string) Option
- func OptionTLSConfig(tlsConfig *tls.Config) Option
- func OptionToken(token string) Option
- func OptionTokenManager(tokenManager manipulate.TokenManager) Option
- type SubscriberOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractCredentials ¶
func ExtractCredentials(manipulator manipulate.Manipulator) (string, string)
ExtractCredentials extracts the username and password from the given manipulator. Note: the given manipulator must be an HTTP Manipulator or it will return an error.
func ExtractEncoding ¶
func ExtractEncoding(manipulator manipulate.Manipulator) elemental.EncodingType
ExtractEncoding returns the encoding used by the given manipulator.
func ExtractEndpoint ¶
func ExtractEndpoint(manipulator manipulate.Manipulator) string
ExtractEndpoint extracts the endpoint url from the given manipulator. Note: the given manipulator must be an HTTP Manipulator or it will return an error.
func ExtractNamespace ¶
func ExtractNamespace(manipulator manipulate.Manipulator) string
ExtractNamespace extracts the default namespace from the given manipulator. Note: the given manipulator must be an HTTP Manipulator or it will return an error.
func ExtractTLSConfig ¶
func ExtractTLSConfig(manipulator manipulate.Manipulator) *tls.Config
ExtractTLSConfig returns a copy of the tls config from the given manipulator. Note: the given manipulator must be an HTTP Manipulator or it will return an error.
func New ¶
func New(ctx context.Context, url string, options ...Option) (manipulate.Manipulator, error)
New returns a maniphttp.Manipulator configured according to the given suite of Option.
func NewHTTPManipulator ¶
func NewHTTPManipulator(url, username, password, namespace string) manipulate.Manipulator
NewHTTPManipulator returns a Manipulator backed by an ReST API.
func NewHTTPManipulatorWithTLS ¶
func NewHTTPManipulatorWithTLS(url, username, password, namespace string, tlsConfig *tls.Config) manipulate.Manipulator
NewHTTPManipulatorWithTLS returns a Manipulator backed by an ReST API using the tls config.
func NewHTTPManipulatorWithTokenManager ¶
func NewHTTPManipulatorWithTokenManager(ctx context.Context, url string, namespace string, tlsConfig *tls.Config, tokenManager manipulate.TokenManager) (manipulate.Manipulator, error)
NewHTTPManipulatorWithTokenManager returns a http backed manipulate.Manipulatorusing the given manipulate.TokenManager to manage the the token.
func NewSubscriber ¶
func NewSubscriber(manipulator manipulate.Manipulator, options ...SubscriberOption) manipulate.Subscriber
NewSubscriber returns a new subscription.
func NewSubscriberWithEndpoint ¶
func NewSubscriberWithEndpoint(manipulator manipulate.Manipulator, endpoint string, recursive bool) manipulate.Subscriber
NewSubscriberWithEndpoint returns a new subscription connecting to specific endpoint.
func SetGlobalHeaders ¶
func SetGlobalHeaders(manipulator manipulate.Manipulator, headers http.Header)
SetGlobalHeaders sets the given headers to all requests that will be sent.
Types ¶
type Option ¶
type Option func(*httpManipulator)
An Option represents a maniphttp.Manipulator option.
func OptionAdditonalHeaders ¶
OptionAdditonalHeaders sets the additional http.Header that will be sent.
func OptionCredentials ¶
OptionCredentials sets the username and password to use for authentication.
func OptionDisableBuiltInRetry ¶
func OptionDisableBuiltInRetry() Option
OptionDisableBuiltInRetry disables the auto retry mechanism built in maniphttp Manipulator. By default, the manipulator will silently retry on communication error 3 times after 1s, 2s, and 3s.
func OptionEncoding ¶
func OptionEncoding(enc elemental.EncodingType) Option
OptionEncoding sets the encoding/decoding type to use.
func OptionHTTPClient ¶
OptionHTTPClient sets internal full *http.Client.
If you use this option you are responsible for configuring the *http.Transport and transport's *tls.Config). OptionHTTPTransport or OptionTLSConfig will have no effect if you use this option.
func OptionHTTPTransport ¶
OptionHTTPTransport sets internal *http.Transport.
If you use this option you are responsible for configuring the *tls.Config. OptionTLSConfig will have no effect if you use this option.
func OptionTLSConfig ¶
OptionTLSConfig sets the tls.Config to use for the manipulator.
func OptionToken ¶
OptionToken sets JWT token. If you use for authentication.
If you also use OptionCredentials or OptionTokenManager, the last one will take precedence.
func OptionTokenManager ¶
func OptionTokenManager(tokenManager manipulate.TokenManager) Option
OptionTokenManager sets manipulate.TokenManager to handle token auto renewal.
If you also use OptionCredentials or OptionToken, the last one will take precedence.
type SubscriberOption ¶
type SubscriberOption func(*subscribeConfig)
SubscriberOption represents option to NewSubscriber.
func SubscriberOptionEndpoint ¶
func SubscriberOptionEndpoint(endpoint string) SubscriberOption
SubscriberOptionEndpoint sets the endpint to connect to. By default it is /events.
func SubscriberOptionNamespace ¶
func SubscriberOptionNamespace(namespace string) SubscriberOption
SubscriberOptionNamespace sets the namespace from where the subscription should start. By default it is the same as the manipulator.
func SubscriberOptionRecursive ¶
func SubscriberOptionRecursive(recursive bool) SubscriberOption
SubscriberOptionRecursive makes the subscriber to listen to events in current namespace and all children.