endpoint

package
v0.14.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeEndpointHookFunc

func DecodeEndpointHookFunc() mapstructure.DecodeHookFunc

Types

type AuthenticationStrategy

type AuthenticationStrategy interface {
	Apply(ctx context.Context, req *http.Request) error
	Hash() []byte
}

type Endpoint

type Endpoint struct {
	URL          string                 `mapstructure:"url"        validate:"required,url"`
	Method       string                 `mapstructure:"method"`
	Retry        *Retry                 `mapstructure:"retry"`
	AuthStrategy AuthenticationStrategy `mapstructure:"auth"`
	Headers      map[string]string      `mapstructure:"headers"`
	HTTPCache    *HTTPCache             `mapstructure:"http_cache"`
}

func (Endpoint) CreateClient

func (e Endpoint) CreateClient(peerName string) *http.Client

func (Endpoint) CreateRequest

func (e Endpoint) CreateRequest(ctx context.Context, body io.Reader, rndr Renderer) (*http.Request, error)

func (Endpoint) Hash

func (e Endpoint) Hash() []byte

func (Endpoint) SendRequest

func (e Endpoint) SendRequest(
	ctx context.Context,
	body io.Reader,
	renderer Renderer,
	reader ...ResponseReader,
) ([]byte, error)

type HTTPCache

type HTTPCache struct {
	Enabled    bool          `mapstructure:"enabled"`
	DefaultTTL time.Duration `mapstructure:"default_ttl"`
}

type RenderFunc

type RenderFunc func(template string) (string, error)

func (RenderFunc) Render

func (f RenderFunc) Render(template string) (string, error)

type Renderer

type Renderer interface {
	Render(template string) (string, error)
}

type ResponseReader

type ResponseReader func(resp *http.Response) ([]byte, error)

type Retry

type Retry struct {
	GiveUpAfter time.Duration `mapstructure:"give_up_after"`
	MaxDelay    time.Duration `mapstructure:"max_delay"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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