Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidContentType = errors.New("invalid content type") ErrEmptyBody = errors.New("empty body") )
Functions ¶
Types ¶
type Blackbox ¶
type Blackbox interface {
contract.HTTPRequester
contract.HTTPWriter
contract.HTTPDoer
}
type Client ¶
type Client interface {
Blackbox
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
DecodeBody(r *http.Request, v any) error
}
func NewClient ¶
func NewClient(c contract.HTTPClient, g contract.GzipUtil, gw contract.GzipWriter, gr contract.GzipReader, m contract.Marshaler, u contract.Unmarshaler) (Client, error)
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.
Click to show internal directories.
Click to hide internal directories.