Documentation
¶
Index ¶
- func DumpRequest() http.HandlerFunc
- type Builder
- type ClientBuilder
- type FormLink
- type HeaderLink
- func (l *HeaderLink) Bind(next http.Handler) http.Handler
- func (l *HeaderLink) With(name, value string, values ...string) *HeaderLink
- func (l *HeaderLink) WithAccept(value string) *HeaderLink
- func (l *HeaderLink) WithAuthorization(value string) *HeaderLink
- func (l *HeaderLink) WithBasicAuth(username, password string) *HeaderLink
- func (l *HeaderLink) WithContentType(value string) *HeaderLink
- func (l *HeaderLink) WithContentTypeFromURLEncoded() *HeaderLink
- func (l *HeaderLink) WithJSONHeaders() *HeaderLink
- func (l *HeaderLink) WithRegexp(name, exp string) *HeaderLink
- func (l *HeaderLink) WithStatusCode(status int) *HeaderLink
- type JSONEncodeHandler
- type Link
- type LinkFunc
- type NoopHandler
- type QueryParameterLink
- func (l *QueryParameterLink) Bind(next http.Handler) http.Handler
- func (l *QueryParameterLink) Strict() *QueryParameterLink
- func (l *QueryParameterLink) With(name, value string) *QueryParameterLink
- func (l *QueryParameterLink) WithRegexp(name, exp string) *QueryParameterLink
- func (l *QueryParameterLink) WithStatusCode(status int) *QueryParameterLink
- func (l *QueryParameterLink) WithValues(values url.Values) *QueryParameterLink
- type RawResponseHandler
- type RequestBodyJSONLink
- type RequestBodyLink
- type ResponseFromFileHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpRequest ¶
func DumpRequest() http.HandlerFunc
DumpRequest logs the full HTTP request to the console, including the body if present.
Types ¶
type Builder ¶
type Builder[T any] struct { // contains filtered or unexported fields }
Builder is a type that facilitates the construction of testable HTTP clients and server. It allows defining routes, attaching middleware, and creating custom HTTP clients.
func NewBuilder ¶
func NewBuilder[T any](clientBuilder ClientBuilder[T], chain ...Link) *Builder[T]
type ClientBuilder ¶
ClientBuilder defines a function type for creating a client of type T based on a httptest.Server instance.
type FormLink ¶
type FormLink struct {
// contains filtered or unexported fields
}
FormLink is a type used for validating and processing form data in HTTP requests. It supports strict validation, predefined values, and regex-based checks to ensure form compliance.
func (*FormLink) UsePostForm ¶
func (*FormLink) WithRegexp ¶
type HeaderLink ¶
type HeaderLink struct {
// contains filtered or unexported fields
}
HeaderLink validates HTTP request headers.
func CheckHeader ¶
func CheckHeader() *HeaderLink
func (*HeaderLink) With ¶
func (l *HeaderLink) With(name, value string, values ...string) *HeaderLink
func (*HeaderLink) WithAccept ¶
func (l *HeaderLink) WithAccept(value string) *HeaderLink
func (*HeaderLink) WithAuthorization ¶
func (l *HeaderLink) WithAuthorization(value string) *HeaderLink
func (*HeaderLink) WithBasicAuth ¶
func (l *HeaderLink) WithBasicAuth(username, password string) *HeaderLink
func (*HeaderLink) WithContentType ¶
func (l *HeaderLink) WithContentType(value string) *HeaderLink
func (*HeaderLink) WithContentTypeFromURLEncoded ¶
func (l *HeaderLink) WithContentTypeFromURLEncoded() *HeaderLink
func (*HeaderLink) WithJSONHeaders ¶
func (l *HeaderLink) WithJSONHeaders() *HeaderLink
func (*HeaderLink) WithRegexp ¶
func (l *HeaderLink) WithRegexp(name, exp string) *HeaderLink
func (*HeaderLink) WithStatusCode ¶
func (l *HeaderLink) WithStatusCode(status int) *HeaderLink
type JSONEncodeHandler ¶
type JSONEncodeHandler struct {
// contains filtered or unexported fields
}
JSONEncodeHandler is a handler that encodes data into JSON and writes it to an HTTP response.
func JSONEncode ¶
func JSONEncode(data any) *JSONEncodeHandler
func (*JSONEncodeHandler) ServeHTTP ¶
func (h *JSONEncodeHandler) ServeHTTP(rw http.ResponseWriter, _ *http.Request)
func (*JSONEncodeHandler) WithStatusCode ¶
func (h *JSONEncodeHandler) WithStatusCode(status int) *JSONEncodeHandler
type NoopHandler ¶
type NoopHandler struct {
// contains filtered or unexported fields
}
NoopHandler is a simple HTTP handler that responds without processing requests.
func Noop ¶
func Noop() *NoopHandler
func (*NoopHandler) ServeHTTP ¶
func (h *NoopHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*NoopHandler) WithHeader ¶
func (h *NoopHandler) WithHeader(name, value string, values ...string) *NoopHandler
func (*NoopHandler) WithStatusCode ¶
func (h *NoopHandler) WithStatusCode(status int) *NoopHandler
type QueryParameterLink ¶
type QueryParameterLink struct {
// contains filtered or unexported fields
}
QueryParameterLink validates query parameters in HTTP requests. The strict flag enforces exact matches with specified query parameters.
func CheckQueryParameter ¶
func CheckQueryParameter() *QueryParameterLink
func (*QueryParameterLink) Strict ¶
func (l *QueryParameterLink) Strict() *QueryParameterLink
func (*QueryParameterLink) With ¶
func (l *QueryParameterLink) With(name, value string) *QueryParameterLink
func (*QueryParameterLink) WithRegexp ¶
func (l *QueryParameterLink) WithRegexp(name, exp string) *QueryParameterLink
func (*QueryParameterLink) WithStatusCode ¶
func (l *QueryParameterLink) WithStatusCode(status int) *QueryParameterLink
func (*QueryParameterLink) WithValues ¶
func (l *QueryParameterLink) WithValues(values url.Values) *QueryParameterLink
type RawResponseHandler ¶
type RawResponseHandler struct {
// contains filtered or unexported fields
}
RawResponseHandler is a custom HTTP handler that serves raw response data.
func RawResponse ¶
func RawResponse(data []byte) *RawResponseHandler
func RawStringResponse ¶
func RawStringResponse(data string) *RawResponseHandler
func (*RawResponseHandler) ServeHTTP ¶
func (h *RawResponseHandler) ServeHTTP(rw http.ResponseWriter, _ *http.Request)
func (*RawResponseHandler) WithHeader ¶
func (h *RawResponseHandler) WithHeader(name, value string, values ...string) *RawResponseHandler
func (*RawResponseHandler) WithStatusCode ¶
func (h *RawResponseHandler) WithStatusCode(status int) *RawResponseHandler
type RequestBodyJSONLink ¶
type RequestBodyJSONLink struct {
// contains filtered or unexported fields
}
RequestBodyJSONLink validates JSON request bodies.
func CheckRequestJSONBody ¶
func CheckRequestJSONBody(body string) *RequestBodyJSONLink
CheckRequestJSONBody creates a RequestBodyJSONLink initialized with a string.
func CheckRequestJSONBodyFromFile ¶
func CheckRequestJSONBodyFromFile(filename string) *RequestBodyJSONLink
CheckRequestJSONBodyFromFile creates a RequestBodyJSONLink initialized with the provided request body file.
func CheckRequestJSONBodyFromStruct ¶
func CheckRequestJSONBodyFromStruct(data any) *RequestBodyJSONLink
CheckRequestJSONBodyFromStruct creates a RequestBodyJSONLink initialized with a struct.
func (*RequestBodyJSONLink) Bind ¶
func (l *RequestBodyJSONLink) Bind(next http.Handler) http.Handler
func (*RequestBodyJSONLink) WithDirectory ¶
func (l *RequestBodyJSONLink) WithDirectory(directory string) *RequestBodyJSONLink
type RequestBodyLink ¶
type RequestBodyLink struct {
// contains filtered or unexported fields
}
RequestBodyLink represents a handler utility to validate HTTP request bodies against a predefined byte slice.
func CheckRequestBody ¶
func CheckRequestBody(body string) *RequestBodyLink
CheckRequestBody creates a RequestBodyLink initialized with the provided request body string.
func CheckRequestBodyFromFile ¶
func CheckRequestBodyFromFile(filename string) *RequestBodyLink
CheckRequestBodyFromFile creates a RequestBodyLink initialized with the provided request body file.
func (*RequestBodyLink) IgnoreWhitespace ¶
func (l *RequestBodyLink) IgnoreWhitespace() *RequestBodyLink
type ResponseFromFileHandler ¶
type ResponseFromFileHandler struct {
// contains filtered or unexported fields
}
ResponseFromFileHandler handles HTTP responses using the content of a file.
func ResponseFromFile ¶
func ResponseFromFile(filename string) *ResponseFromFileHandler
func ResponseFromFixture ¶
func ResponseFromFixture(filename string) *ResponseFromFileHandler
func (*ResponseFromFileHandler) ServeHTTP ¶
func (h *ResponseFromFileHandler) ServeHTTP(rw http.ResponseWriter, _ *http.Request)
func (*ResponseFromFileHandler) WithHeader ¶
func (h *ResponseFromFileHandler) WithHeader(name, value string, values ...string) *ResponseFromFileHandler
func (*ResponseFromFileHandler) WithStatusCode ¶
func (h *ResponseFromFileHandler) WithStatusCode(status int) *ResponseFromFileHandler