httpsecure

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthMethodJWT       = "jwt"
	AuthMethodAdminKeys = "admin_keys"
	AuthMethodAccessKey = "access_key"
)

Variables

View Source
var (
	// ErrEntityNotFound indicates the API entity was not found
	ErrEntityNotFound = errors.New("entity not found")
	// ErrOperationTimedOut indicates the request has timed out
	ErrOperationTimedOut = errors.New("operation timed out")
)

Functions

This section is empty.

Types

type AuthenticationFunc

type AuthenticationFunc func(pc *Client) error

func WithAccessKey

func WithAccessKey(apiKey, clientSecret string) AuthenticationFunc

WithAccessKey - authentication with access keys

func WithAdminKeys

func WithAdminKeys(adminKey, adminSecret string) AuthenticationFunc

WithAdminKeys - authentication with admin keys

func WithJWTToken

func WithJWTToken(jwtToken string) AuthenticationFunc

WithJWTToken - authentication with JWT token

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(source, userAgent string, timeout time.Duration, authFunc AuthenticationFunc) (*Client, error)

NewHTTPClient returns a client with the requested config

func (*Client) CloseIdleConnections

func (c *Client) CloseIdleConnections()

func (*Client) Copy

func (c *Client) Copy(authFunc AuthenticationFunc) (*Client, error)

func (*Client) DialWebSocket

func (c *Client) DialWebSocket(relativeURL string) (*websocket.Conn, error)

func (*Client) GetAuthMethod

func (c *Client) GetAuthMethod() string

GetAuthMethod - returning authorization method

func (*Client) GetConnectionURL

func (c *Client) GetConnectionURL() string

GetConnectionURL - returning client connection url

func (*Client) GetHTTPClient

func (c *Client) GetHTTPClient() *http.Client

GetHTTPClient - returning http client

func (*Client) GetToken

func (c *Client) GetToken() string

GetToken - returning JWT token

func (*Client) GetUserAgent

func (c *Client) GetUserAgent() string

GetUserAgent - returning client user agent

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

IsAuthenticated - check authentificaion

func (*Client) LoadContents

func (c *Client) LoadContents(method, contentURL string, headerValues map[string]string, val any) error

func (*Client) Logout

func (c *Client) Logout()

Logout - clearing authorisation info

func (*Client) SendRequest

func (c *Client) SendRequest(method, requestURL string, opts ...Option) (*http.Response, error)

type Option

type Option func(opts *requestOptions) error

func SkipAuthentication

func SkipAuthentication() Option

func WithBody

func WithBody(body io.Reader) Option

func WithHeaders

func WithHeaders(headers map[string]string) Option

func WithJSONBody

func WithJSONBody(val any) Option

func WithUnsignedBody

func WithUnsignedBody(body io.Reader) Option

Jump to

Keyboard shortcuts

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