client

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConflict

func IsConflict(err error) bool

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

Types

type APIResponse

type APIResponse struct {
	Error *Error `json:"error,omitempty"`
}

APIResponse ...

type Client

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

Client ...

func New

func New(urs string) (*Client, error)

New creates a Client for the a Web API.

func (*Client) Clock

func (c *Client) Clock() tsutil.Clock

func (*Client) HTTPClient

func (c *Client) HTTPClient() *nethttp.Client

HTTPClient we are using.

func (*Client) Request

func (c *Client) Request(ctx context.Context, req *Request) (*Response, error)

Request makes a request.

func (*Client) SetClock

func (c *Client) SetClock(clock tsutil.Clock)

SetClock sets the clock Now fn.

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(httpClient *nethttp.Client)

SetHTTPClient sets the http.Client to use.

func (*Client) URL

func (c *Client) URL() *url.URL

URL ...

type Error

type Error struct {
	Message string `json:"message,omitempty"`
	Status  int    `json:"status,omitempty"`
}

Error ...

func (Error) Error

func (e Error) Error() string

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type Metadata

type Metadata struct {
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Metadata ...

type Request

type Request struct {
	Method string
	Path   string
	Params url.Values
	Body   []byte
	// Key is shortcut for []Auths{{Header: "Authorization", Key: Key}}
	Key      *keys.EdX25519Key
	Headers  []http.Header
	Progress func(n int64)
	Auths    []http.AuthHeader
}

Request ...

func GET

func GET(path string, key *keys.EdX25519Key) *Request

GET request.

func PUT

func PUT(path string, body []byte, key *keys.EdX25519Key) *Request

PUT request.

type Response

type Response struct {
	Data      []byte
	CreatedAt time.Time
	UpdatedAt time.Time
}

Response ...

Jump to

Keyboard shortcuts

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