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 SurroundingLogRequest ¶ added in v0.16.6
type SurroundingLogResponse ¶ added in v0.16.6
Click to show internal directories.
Click to hide internal directories.