contract

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationOptions

type AuthorizationOptions interface {
	Bearer() string

	SetBearer(bearer string)

	Basic() BasicAuthorizationOptions

	SetBasic(basic BasicAuthorizationOptions)
}

type BasicAuthorizationOptions

type BasicAuthorizationOptions interface {
	Username() string

	SetUsername(username string)

	Password() string

	SetPassword(password string)
}

type Client

type Client interface {
	Get(urlString string, options ...RequestOption) (Response, error)

	Post(urlString string, body any, options ...RequestOption) (Response, error)

	Put(urlString string, body any, options ...RequestOption) (Response, error)

	Patch(urlString string, body any, options ...RequestOption) (Response, error)

	Delete(urlString string, options ...RequestOption) (Response, error)

	Request(method string, urlString string, options ...RequestOption) (Response, error)

	RequestStream(method string, urlString string, options ...RequestOption) (StreamResponse, error)
}

type RequestOption

type RequestOption func(RequestOptions)

type RequestOptions

type RequestOptions interface {
	Headers() map[string]string

	Query() map[string]string

	Body() any

	ContentType() string

	Timeout() time.Duration

	Authorization() AuthorizationOptions

	MaxResponseBodyBytes() int

	SetMaxResponseBodyBytes(maxResponseBodyBytes int)

	SetHeader(key string, value string)

	SetHeaders(headers map[string]string)

	SetQuery(key string, value string)

	SetQueryParams(parameters map[string]string)

	SetBody(body any)

	SetJson(data any)

	SetTimeout(timeout time.Duration)

	SetBearerToken(token string)

	SetBasicAuth(username string, password string)
}

type Response

type Response interface {
	StatusCode() int

	Status() string

	Headers() nethttp.Header

	Body() []byte

	Request() *nethttp.Request

	Json(target any) error

	String() string

	IsSuccess() bool

	IsClientError() bool

	IsServerError() bool
}

type StreamResponse

type StreamResponse interface {
	StatusCode() int

	Headers() nethttp.Header

	Body() io.ReadCloser

	Close() error
}

Jump to

Keyboard shortcuts

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