Documentation ¶
Index ¶
- Variables
- func AssertHTTPResponseBodyLength(t *testing.T, resp *http.Response, n int64) (ok bool)
- func AssertHTTPResponseContentLength(t *testing.T, resp *http.Response, n int64) (ok bool)
- func AssertHTTPResponseHeader(t *testing.T, resp *http.Response, key, format string, a ...interface{}) (ok bool)
- func AssertHTTPResponseStatusCode(t *testing.T, resp *http.Response, expect int) (ok bool)
- func AssertSHA256Sum(t *testing.T, sum []byte, r io.Reader) (ok bool)
- func MustHTTPDo(req *http.Request) *http.Response
- func MustHTTPDoWithClose(req *http.Request) *http.Response
- func MustHTTPNewRequest(method, url string, body io.Reader) *http.Request
- func MustHexDecodeString(s string) (b []byte)
- func MustHexEncodeString(b []byte) (s string)
- func NewHandler(options ...HandlerOption) (http.Handler, error)
- func WithTestServer(t *testing.T, f func(url string), options ...HandlerOption)
- type HandlerOption
- func AcceptRanges(enabled bool) HandlerOption
- func AttachmentFilename(filename string) HandlerOption
- func ContentLength(n int) HandlerOption
- func HeaderBlacklist(headers ...string) HandlerOption
- func LastModified(t time.Time) HandlerOption
- func MethodWhitelist(methods ...string) HandlerOption
- func RateLimiter(bps int) HandlerOption
- func StatusCode(f StatusCodeFunc) HandlerOption
- func StatusCodeStatic(code int) HandlerOption
- func TimeToFirstByte(d time.Duration) HandlerOption
- type StatusCodeFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultHandlerContentLength = 1 << 20 DefaultHandlerMD5Checksum = "c35cc7d8d91728a0cb052831bc4ef372" DefaultHandlerMD5ChecksumBytes = MustHexDecodeString(DefaultHandlerMD5Checksum) DefaultHandlerSHA256Checksum = "fbbab289f7f94b25736c58be46a994c441fd02552cc6022352e3d86d2fab7c83" DefaultHandlerSHA256ChecksumBytes = MustHexDecodeString(DefaultHandlerSHA256Checksum) )
Functions ¶
func MustHexDecodeString ¶
func MustHexEncodeString ¶
func NewHandler ¶
func NewHandler(options ...HandlerOption) (http.Handler, error)
func WithTestServer ¶
func WithTestServer(t *testing.T, f func(url string), options ...HandlerOption)
Types ¶
type HandlerOption ¶
type HandlerOption func(*handler) error
func AcceptRanges ¶
func AcceptRanges(enabled bool) HandlerOption
func AttachmentFilename ¶
func AttachmentFilename(filename string) HandlerOption
func ContentLength ¶
func ContentLength(n int) HandlerOption
func HeaderBlacklist ¶
func HeaderBlacklist(headers ...string) HandlerOption
func LastModified ¶
func LastModified(t time.Time) HandlerOption
func MethodWhitelist ¶
func MethodWhitelist(methods ...string) HandlerOption
func RateLimiter ¶
func RateLimiter(bps int) HandlerOption
func StatusCode ¶
func StatusCode(f StatusCodeFunc) HandlerOption
func StatusCodeStatic ¶
func StatusCodeStatic(code int) HandlerOption
func TimeToFirstByte ¶
func TimeToFirstByte(d time.Duration) HandlerOption
type StatusCodeFunc ¶
Click to show internal directories.
Click to hide internal directories.