client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTPTimeout time.Duration
	CommandName string

	Logger log.Logger
	// contains filtered or unexported fields
}

Client is the default wrapper around an http client extra helpers for our APIs around using bearer tokens

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new default client with no options set This is typically just passed into a service call like

notifications.NewNotificationSvc(client.NewClient())

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do will run the HTTP request and add a bearer if the client was setup with a token optionally you can set a env var of `CURL_DEBUG=true` to get curl output printed out for easier debugging

func (*Client) Header

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

type Option

type Option func(*Client)

Option is used for setting client options for the SDK

func WithBearerToken

func WithBearerToken(in string) Option

WithBearerToken lets you set a token to include with every request

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets the underlying http client for use with requests, overrides default of http.DefaultClient

func WithHTTPTimeout

func WithHTTPTimeout(in time.Duration) Option

WithHTTPTimeout sets how long the request has to finish, this defaults to 5 seconds

func WithHeader

func WithHeader(header http.Header) Option

WithHeader lets you add additional header values to all requests

func WithLogger

func WithLogger(in log.Logger) Option

WithLogger sets the underlying logger to be used with any Client passing through the returned Option

func WithTenant

func WithTenant(in string) Option

WithTenant lets you set a tenant id with every request

Jump to

Keyboard shortcuts

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