client

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[K, V any](ctx context.Context, d Doer, body *K, response *V) error

Types

type Client

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

func New

func New(conf *Config) *Client

func (Client) Prepare

func (c Client) Prepare(path string, method string) *Request

func (*Client) SetHeader

func (c *Client) SetHeader(key, value string)

func (*Client) SetToken

func (c *Client) SetToken(token string)

type Config

type Config struct {
	BaseURI string
	Token   string
	Logger  Logger
	Headers map[string]string
}

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
	RequestURI() string
	Method() string
	Token() string
	Logger() Logger
	Header() map[string]string
	UnmarshalBody(*http.Response, any) error
}

type Logger

type Logger interface {
	Infof(string, ...any)
	Debugf(string, ...any)
}

type Request

type Request struct {
	Path string
	// contains filtered or unexported fields
}

func (Request) Do

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

func (Request) Header

func (r Request) Header() map[string]string

func (Request) Logger

func (r Request) Logger() Logger

func (Request) Method

func (r Request) Method() string

func (Request) RequestURI

func (r Request) RequestURI() string

func (*Request) SetHeader

func (r *Request) SetHeader(m map[string]string)

func (Request) Token

func (r Request) Token() string

func (*Request) UnmarshalBody

func (r *Request) UnmarshalBody(res *http.Response, v any) error

Jump to

Keyboard shortcuts

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