api

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_TIMEOUT = 10 * time.Second

DEFAULT_TIMEOUT the default timeout of team specification.

Functions

func ToObject

func ToObject[T any](obj HTTPResponse) (T, error)

ToObject transform HTTPResponse.GetBody to any object using json encoding.

Types

type HTTPClient added in v0.16.0

type HTTPClient interface {
	// Call send given request using HTTP, and optionally set custom timeout if
	// provided, otherwise will use DEFAULT_TIMEOUT.
	//
	// This function also help setting any necessary metadata for spotlibs using
	// ctx pkg that also come from this lib.
	Call(req *http.Request, timeouts ...time.Duration) (HTTPResponse, error)
}

func NewHTTPClient added in v0.16.0

func NewHTTPClient() HTTPClient

NewHTTPClient return HTTPClient implementer that also set some metadata header before sending the request.

type HTTPResponse added in v0.16.0

type HTTPResponse interface {
	// GetStatusCode get the http status code.
	GetStatusCode() int
	// GetBody get the raw response body in bytes.
	GetBody() []byte
	// GetHeaders get the original response header, after combining the value to
	// one using comma.
	GetHeaders() map[string]string
	// GetHeader get the response header by the given key after combining the value
	// using comma.
	GetHeader(key string) string
}

Jump to

Keyboard shortcuts

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