Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Blackbox ¶
type Blackbox interface {
contract.HTTPRequester
contract.HTTPWriter
}
WARN: Methods from this interface require black-box testing because they internally call package-level functions (e.g., http.NewRequest) that are not easily mockable or stubbable. While we have access to their implementation, mocking or stubbing these functions is not practical. As a result, these methods are best tested using black-box testing techniques, such as input-based testing, where explicit error scenarios are triggered. Alternatively, these methods can also be tested using function variables.
type Client ¶
type Client interface {
Blackbox
contract.HTTPDoer
contract.HTTPWriter
QueryString(pairs ...string) string
RespondJSON(w http.ResponseWriter, v any, status int, escapeHTML bool) error
RespondError(w http.ResponseWriter, status int, escapeHTML bool)
RespondGzipJSON(w http.ResponseWriter, v any, status int, escapeHTML bool) error
RespondGzipError(w http.ResponseWriter, status int, escapeHTML bool)
ValidateQueryParams(q map[string][]string, rules ...*QueryParamRule) error
ServeHTML(w http.ResponseWriter, body io.Reader, status int)
CopyHeaders(dst, src *http.Request, headers ...string)
GetHeaders(r *http.Request) http.Header
}
type QueryParamRule ¶
type QueryParamRule struct {
Key string // Name of the query parameter.
DefaultValue string // Default value if not provided in the request.
AcceptedValues []string // Accepted values; nil allows any value.
MultipleValuesAllowed bool // Whether multiple values are permitted.
Optional bool // Whether the parameter is optional.
}
QueryParamRule defines validation rules for a query parameter. It specifies constraints such as key, default value, allowed values, and multiplicity.