api

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 20 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 ClientExternalSurroundingLog added in v0.16.6

type ClientExternalSurroundingLog struct {
	AppName      string                 `json:"app_name"`
	Path         string                 `json:"path"`
	Host         string                 `json:"host"`
	Url          string                 `json:"url"`
	Request      SurroundingLogRequest  `json:"request"`
	Response     SurroundingLogResponse `json:"response"`
	ResponseTime time.Duration          `json:"response_time"`
	MemoryUsage  uint64                 `json:"memory_usage"`
}

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 HTTPClientExternal added in v0.16.6

type HTTPClientExternal 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(requestClient context.Context, req *http.Request, timeouts ...time.Duration) (HTTPResponse, error)
}

func NewHTTPClientExternal added in v0.16.6

func NewHTTPClientExternal() HTTPClientExternal

NewHTTPClientExternal 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
}

type MapRoute added in v0.16.6

type MapRoute struct {
	Flag    bool   `json:"flag"`
	MockURL string `json:"mock_url"`
}

type SurroundingLogRequest added in v0.16.6

type SurroundingLogRequest struct {
	Method string `json:"method"`
	Header any    `json:"header"`
	Body   any    `json:"body"`
}

type SurroundingLogResponse added in v0.16.6

type SurroundingLogResponse struct {
	HttpCode int `json:"http_code"`
	Header   any `json:"header"`
	Body     any `json:"body"`
}

Jump to

Keyboard shortcuts

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