api

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 6 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 Response) (T, error)

ToObject transform Response.Body to any object using json encoding.

Types

type HTTPAgent

type HTTPAgent interface {
	// Do 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.
	Do(req *http.Request, timeouts ...time.Duration) (Response, error)
}

func NewHTTPAgent

func NewHTTPAgent() HTTPAgent

NewHTTPAgent return HTTPAgent implementer that also set some metadata header before sending the request.

type Response

type Response struct {
	StatusCode int
	Body       []byte
	Header     map[string][]string
}

Response object that may be returned by Agent.

Jump to

Keyboard shortcuts

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