apiutil

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 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 Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer abstracts the ability to execute HTTP requests.

type Result

type Result struct {
	StatusCode int
	Body       []byte
	Header     http.Header
}

Result represents a simplified HTTP response payload.

func Request

func Request(
	ctx context.Context,
	client Doer,
	method string,
	baseURL string,
	path string,
	token string,
	headers map[string]string,
	body io.Reader,
) (*Result, error)

Request issues an HTTP request against the provided endpoint. If the provided path is not absolute it is resolved against the base URL. Headers are merged with defaults where the caller provided values take precedence.

func RequestWithTokenSource added in v0.10.0

func RequestWithTokenSource(
	ctx context.Context,
	client Doer,
	method string,
	baseURL string,
	path string,
	tokenSource TokenSource,
	headers map[string]string,
	body io.Reader,
) (*Result, error)

type StaticTokenSource added in v0.10.0

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

func NewStaticTokenSource added in v0.10.0

func NewStaticTokenSource(token string) StaticTokenSource

func (StaticTokenSource) Refresh added in v0.10.0

func (StaticTokenSource) Refreshable added in v0.10.0

func (s StaticTokenSource) Refreshable() bool

func (StaticTokenSource) Token added in v0.10.0

type TokenSource added in v0.10.0

type TokenSource interface {
	Token(ctx context.Context) (string, error)
	Refresh(ctx context.Context, previousToken string) (string, error)
}

Jump to

Keyboard shortcuts

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