manipulate: go.aporeto.io/manipulate/maniphttp Index | Files | Directories

package maniphttp

import "go.aporeto.io/manipulate/maniphttp"

Package maniphttp provides a ReST backed Manipulator.

This is meant to be use to communicate with Bahamut based API servers.

Index

Package Files

doc.go helpers.go manipulator.go options.go retryinfo.go subscriber.go utils.go

func DirectSend Uses

func DirectSend(manipulator manipulate.Manipulator, mctx manipulate.Context, endpoint string, method string, body []byte) (*http.Response, error)

DirectSend allows to send direct bytes using the given manipulator. This is only useful in extremely particular scenario, like fuzzing.

func ExtractCredentials Uses

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 Uses

func ExtractEncoding(manipulator manipulate.Manipulator) elemental.EncodingType

ExtractEncoding returns the encoding used by the given manipulator.

func ExtractEndpoint Uses

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 Uses

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 Uses

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 Uses

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 NewSubscriber Uses

func NewSubscriber(manipulator manipulate.Manipulator, options ...SubscriberOption) manipulate.Subscriber

NewSubscriber returns a new subscription.

func NewSubscriberWithEndpoint Uses

func NewSubscriberWithEndpoint(manipulator manipulate.Manipulator, endpoint string, recursive bool) manipulate.Subscriber

NewSubscriberWithEndpoint returns a new subscription connecting to specific endpoint.

func SetGlobalHeaders Uses

func SetGlobalHeaders(manipulator manipulate.Manipulator, headers http.Header)

SetGlobalHeaders sets the given headers to all requests that will be sent.

type Option Uses

type Option func(*httpManipulator)

An Option represents a maniphttp.Manipulator option.

func OptionAdditonalHeaders Uses

func OptionAdditonalHeaders(headers http.Header) Option

OptionAdditonalHeaders sets the additional http.Header that will be sent.

func OptionCredentials Uses

func OptionCredentials(username, password string) Option

OptionCredentials sets the username and password to use for authentication.

func OptionDefaultRetryFunc Uses

func OptionDefaultRetryFunc(f manipulate.RetryFunc) Option

OptionDefaultRetryFunc sets the default retry func to use if manipulate.Context does not have one.

func OptionDisableBuiltInRetry Uses

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 OptionDisableCompression Uses

func OptionDisableCompression() Option

OptionDisableCompression disables the gzip compression in http transport. This only has effect if you don't set a custom transport.

func OptionEncoding Uses

func OptionEncoding(enc elemental.EncodingType) Option

OptionEncoding sets the encoding/decoding type to use.

func OptionHTTPClient Uses

func OptionHTTPClient(client *http.Client) Option

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 Uses

func OptionHTTPTransport(transport *http.Transport) Option

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 OptionNamespace Uses

func OptionNamespace(ns string) Option

OptionNamespace sets the namespace.

func OptionSimulateFailures Uses

func OptionSimulateFailures(failureSimulations map[float64]error) Option

OptionSimulateFailures will inject random error during low level communication with the remote API.

The key of the map is a float between 0 and 1 that will give the percentage of chance for simulating the failure, and error it should return.

For instance, take the following map:

map[float64]error{
    0.10: manipulate.NewErrCannotBuildQuery("oh no"),
    0.25: manipulate.NewErrCannotCommunicate("service is gone"),
}

It will return manipulate.NewErrCannotBuildQuery around 10% of the requests, manipulate.NewErrCannotCommunicate around 25% of the requests. This is obviously designed for simulating backend failures and should not be used in production, obviously.

func OptionTLSConfig Uses

func OptionTLSConfig(tlsConfig *tls.Config) Option

OptionTLSConfig sets the tls.Config to use for the manipulator.

func OptionToken Uses

func OptionToken(token string) Option

OptionToken sets JWT token. If you use for authentication.

If you also use OptionCredentials or OptionTokenManager, the last one will take precedence.

func OptionTokenManager Uses

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 RetryInfo Uses

type RetryInfo struct {
    URL    string
    Method string
    // contains filtered or unexported fields
}

A RetryInfo contains information about a retry,

func (RetryInfo) Context Uses

func (i RetryInfo) Context() manipulate.Context

Context returns the manipulate.Context used.

func (RetryInfo) Err Uses

func (i RetryInfo) Err() error

Err returns the error that caused the retry.

func (RetryInfo) Try Uses

func (i RetryInfo) Try() int

Try returns the try number.

type SubscriberOption Uses

type SubscriberOption func(*subscribeConfig)

SubscriberOption represents option to NewSubscriber.

func SubscriberOptionEndpoint Uses

func SubscriberOptionEndpoint(endpoint string) SubscriberOption

SubscriberOptionEndpoint sets the endpint to connect to. By default it is /events.

func SubscriberOptionNamespace Uses

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 Uses

func SubscriberOptionRecursive(recursive bool) SubscriberOption

SubscriberOptionRecursive makes the subscriber to listen to events in current namespace and all children.

Directories

PathSynopsis
internal/compiler

Package maniphttp imports 26 packages (graph). Updated 2019-11-15. Refresh now. Tools for package owners.