Documentation ¶
Overview ¶
htest is a http test package
import "github.com/Hexilee/htest"
Index ¶
- Constants
- type Client
- func (c Client) Connect(path string) *Request
- func (c Client) Delete(path string) *Request
- func (c Client) Get(path string) *Request
- func (c Client) Head(path string) *Request
- func (c Client) NewRequest(req *http.Request) *Request
- func (c Client) Options(path string) *Request
- func (c Client) Patch(path string, body io.Reader) *Request
- func (c Client) Post(path string, body io.Reader) *Request
- func (c Client) Put(path string, body io.Reader) *Request
- func (c Client) To(handler http.Handler) *Client
- func (c Client) ToFunc(handlerFunc http.HandlerFunc) *Client
- func (c Client) Trace(path string) *Request
- type JSON
- func (j *JSON) Bind(obj interface{}) error
- func (j *JSON) Body() []byte
- func (j *JSON) Empty() *JSON
- func (j *JSON) Exist(key string) *JSON
- func (j *JSON) False(key string) *JSON
- func (j *JSON) Float(key string, expect float64) *JSON
- func (j *JSON) GetKey(key string) (result gjson.Result, exist bool)
- func (j *JSON) Int(key string, expect int64) *JSON
- func (j *JSON) NotEmpty() *JSON
- func (j *JSON) NotExist(key string) *JSON
- func (j *JSON) String(key, expect string) *JSON
- func (j *JSON) Time(key string, expect time.Time) *JSON
- func (j *JSON) True(key string) *JSON
- func (j *JSON) Uint(key string, expect uint64) *JSON
- type MD5
- type Request
- type Response
- func (r *Response) Bind(obj interface{}) error
- func (r *Response) Bytes() []byte
- func (r *Response) Code(statusCode int) *Response
- func (r *Response) Expect(expect string)
- func (r *Response) HeaderAccept(expect string) *Response
- func (r *Response) HeaderAcceptEncoding(expect string) *Response
- func (r *Response) HeaderAccessControlAllowCredentials(expect string) *Response
- func (r *Response) HeaderAccessControlAllowHeaders(expect string) *Response
- func (r *Response) HeaderAccessControlAllowMethods(expect string) *Response
- func (r *Response) HeaderAccessControlAllowOrigin(expect string) *Response
- func (r *Response) HeaderAccessControlExposeHeaders(expect string) *Response
- func (r *Response) HeaderAccessControlMaxAge(expect string) *Response
- func (r *Response) HeaderAccessControlRequestHeaders(expect string) *Response
- func (r *Response) HeaderAccessControlRequestMethod(expect string) *Response
- func (r *Response) HeaderAllow(expect string) *Response
- func (r *Response) HeaderAuthorization(expect string) *Response
- func (r *Response) HeaderContentDisposition(expect string) *Response
- func (r *Response) HeaderContentEncoding(expect string) *Response
- func (r *Response) HeaderContentLength(expect string) *Response
- func (r *Response) HeaderContentSecurityPolicy(expect string) *Response
- func (r *Response) HeaderContentType(expect string) *Response
- func (r *Response) HeaderCookie(expect string) *Response
- func (r *Response) HeaderIfModifiedSince(expect string) *Response
- func (r *Response) HeaderLastModified(expect string) *Response
- func (r *Response) HeaderLocation(expect string) *Response
- func (r *Response) HeaderOrigin(expect string) *Response
- func (r *Response) HeaderServer(expect string) *Response
- func (r *Response) HeaderSetCookie(expect string) *Response
- func (r *Response) HeaderStrictTransportSecurity(expect string) *Response
- func (r *Response) HeaderUpgrade(expect string) *Response
- func (r *Response) HeaderVary(expect string) *Response
- func (r *Response) HeaderWWWAuthenticate(expect string) *Response
- func (r *Response) HeaderXCSRFToken(expect string) *Response
- func (r *Response) HeaderXContentTypeOptions(expect string) *Response
- func (r *Response) HeaderXForwardedFor(expect string) *Response
- func (r *Response) HeaderXForwardedProto(expect string) *Response
- func (r *Response) HeaderXForwardedProtocol(expect string) *Response
- func (r *Response) HeaderXForwardedSsl(expect string) *Response
- func (r *Response) HeaderXFrameOptions(expect string) *Response
- func (r *Response) HeaderXHTTPMethodOverride(expect string) *Response
- func (r *Response) HeaderXRealIP(expect string) *Response
- func (r *Response) HeaderXRequestID(expect string) *Response
- func (r *Response) HeaderXUrlScheme(expect string) *Response
- func (r *Response) HeaderXXSSProtection(expect string) *Response
- func (r *Response) Headers(key, expect string) *Response
- func (r *Response) JSON() *JSON
- func (r *Response) MD5() *MD5
- func (r *Response) SHA1() *SHA1
- func (r *Response) StatusAccepted() *Response
- func (r *Response) StatusAlreadyReported() *Response
- func (r *Response) StatusBadGateway() *Response
- func (r *Response) StatusBadRequest() *Response
- func (r *Response) StatusConflict() *Response
- func (r *Response) StatusContinue() *Response
- func (r *Response) StatusCreated() *Response
- func (r *Response) StatusExpectationFailed() *Response
- func (r *Response) StatusFailedDependency() *Response
- func (r *Response) StatusForbidden() *Response
- func (r *Response) StatusFound() *Response
- func (r *Response) StatusGatewayTimeout() *Response
- func (r *Response) StatusGone() *Response
- func (r *Response) StatusHTTPVersionNotSupported() *Response
- func (r *Response) StatusIMUsed() *Response
- func (r *Response) StatusInsufficientStorage() *Response
- func (r *Response) StatusInternalServerError() *Response
- func (r *Response) StatusLengthRequired() *Response
- func (r *Response) StatusLocked() *Response
- func (r *Response) StatusLoopDetected() *Response
- func (r *Response) StatusMethodNotAllowed() *Response
- func (r *Response) StatusMovedPermanently() *Response
- func (r *Response) StatusMultiStatus() *Response
- func (r *Response) StatusMultipleChoices() *Response
- func (r *Response) StatusNetworkAuthenticationRequired() *Response
- func (r *Response) StatusNoContent() *Response
- func (r *Response) StatusNonAuthoritativeInfo() *Response
- func (r *Response) StatusNotAcceptable() *Response
- func (r *Response) StatusNotExtended() *Response
- func (r *Response) StatusNotFound() *Response
- func (r *Response) StatusNotImplemented() *Response
- func (r *Response) StatusNotModified() *Response
- func (r *Response) StatusOK() *Response
- func (r *Response) StatusPartialContent() *Response
- func (r *Response) StatusPaymentRequired() *Response
- func (r *Response) StatusPermanentRedirect() *Response
- func (r *Response) StatusPreconditionFailed() *Response
- func (r *Response) StatusPreconditionRequired() *Response
- func (r *Response) StatusProcessing() *Response
- func (r *Response) StatusProxyAuthRequired() *Response
- func (r *Response) StatusRequestEntityTooLarge() *Response
- func (r *Response) StatusRequestHeaderFieldsTooLarge() *Response
- func (r *Response) StatusRequestTimeout() *Response
- func (r *Response) StatusRequestURITooLong() *Response
- func (r *Response) StatusRequestedRangeNotSatisfiable() *Response
- func (r *Response) StatusResetContent() *Response
- func (r *Response) StatusSeeOther() *Response
- func (r *Response) StatusServiceUnavailable() *Response
- func (r *Response) StatusSwitchingProtocols() *Response
- func (r *Response) StatusTeapot() *Response
- func (r *Response) StatusTemporaryRedirect() *Response
- func (r *Response) StatusTooManyRequests() *Response
- func (r *Response) StatusUnauthorized() *Response
- func (r *Response) StatusUnavailableForLegalReasons() *Response
- func (r *Response) StatusUnprocessableEntity() *Response
- func (r *Response) StatusUnsupportedMediaType() *Response
- func (r *Response) StatusUpgradeRequired() *Response
- func (r *Response) StatusUseProxy() *Response
- func (r *Response) StatusVariantAlsoNegotiates() *Response
- func (r *Response) String() string
- func (r *Response) XML() *XML
- type SHA1
- type XML
- func (x *XML) Bind(obj interface{}) error
- func (x *XML) Body() []byte
- func (x *XML) Empty() *XML
- func (x *XML) Exist(key string) *XML
- func (x *XML) False(key string) *XML
- func (x *XML) Float(key string, expect float64) *XML
- func (x *XML) Int(key string, expect int64) *XML
- func (x *XML) NotEmpty() *XML
- func (x *XML) NotExist(key string) *XML
- func (x *XML) String(key, expect string) *XML
- func (x *XML) Time(key string, expect time.Time) *XML
- func (x *XML) True(key string) *XML
- func (x *XML) Uint(key string, expect uint64) *XML
Constants ¶
View Source
const ( CONNECT = "CONNECT" DELETE = "DELETE" GET = "GET" HEAD = "HEAD" OPTIONS = "OPTIONS" PATCH = "PATCH" POST = "POST" PUT = "PUT" TRACE = "TRACE" )
HTTP methods
View Source
const ( MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 MIMEApplicationJavaScript = "application/javascript" MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8 MIMEApplicationXML = "application/xml" MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + charsetUTF8 MIMETextXML = "text/xml" MIMETextXMLCharsetUTF8 = MIMETextXML + "; " + charsetUTF8 MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationProtobuf = "application/protobuf" MIMEApplicationMsgpack = "application/msgpack" MIMETextHTML = "text/html" MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + charsetUTF8 MIMETextPlain = "text/plain" MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + charsetUTF8 MIMEMultipartForm = "multipart/form-data" MIMEOctetStream = "application/octet-stream" )
MIME types
View Source
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXRealIP = "X-Real-IP" HeaderXRequestID = "X-Request-ID" HeaderServer = "Server" HeaderOrigin = "Origin" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderXCSRFToken = "X-CSRF-Token" )
Headers
View Source
const (
MockNilError = "Request.Handler cannot be nil, had you called Client.To or Client.ToFunc?"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
func (*Response) HeaderAccept ¶ added in v0.5.0
func (*Response) HeaderAcceptEncoding ¶ added in v0.5.0
func (*Response) HeaderAccessControlAllowCredentials ¶ added in v0.5.0
func (*Response) HeaderAccessControlAllowHeaders ¶ added in v0.5.0
func (*Response) HeaderAccessControlAllowMethods ¶ added in v0.5.0
func (*Response) HeaderAccessControlAllowOrigin ¶ added in v0.5.0
func (*Response) HeaderAccessControlExposeHeaders ¶ added in v0.5.0
func (*Response) HeaderAccessControlMaxAge ¶ added in v0.5.0
func (*Response) HeaderAccessControlRequestHeaders ¶ added in v0.5.0
func (*Response) HeaderAccessControlRequestMethod ¶ added in v0.5.0
func (*Response) HeaderAllow ¶ added in v0.5.0
func (*Response) HeaderAuthorization ¶ added in v0.5.0
func (*Response) HeaderContentDisposition ¶ added in v0.5.0
func (*Response) HeaderContentEncoding ¶ added in v0.5.0
func (*Response) HeaderContentLength ¶ added in v0.5.0
func (*Response) HeaderContentSecurityPolicy ¶ added in v0.5.0
func (*Response) HeaderContentType ¶ added in v0.5.0
func (*Response) HeaderCookie ¶ added in v0.5.0
func (*Response) HeaderIfModifiedSince ¶ added in v0.5.0
func (*Response) HeaderLastModified ¶ added in v0.5.0
func (*Response) HeaderLocation ¶ added in v0.5.0
func (*Response) HeaderOrigin ¶ added in v0.5.0
func (*Response) HeaderServer ¶ added in v0.5.0
func (*Response) HeaderSetCookie ¶ added in v0.5.0
func (*Response) HeaderStrictTransportSecurity ¶ added in v0.5.0
func (*Response) HeaderUpgrade ¶ added in v0.5.0
func (*Response) HeaderVary ¶ added in v0.5.0
func (*Response) HeaderWWWAuthenticate ¶ added in v0.5.0
func (*Response) HeaderXCSRFToken ¶ added in v0.5.0
func (*Response) HeaderXContentTypeOptions ¶ added in v0.5.0
func (*Response) HeaderXForwardedFor ¶ added in v0.5.0
func (*Response) HeaderXForwardedProto ¶ added in v0.5.0
func (*Response) HeaderXForwardedProtocol ¶ added in v0.5.0
func (*Response) HeaderXForwardedSsl ¶ added in v0.5.0
func (*Response) HeaderXFrameOptions ¶ added in v0.5.0
func (*Response) HeaderXHTTPMethodOverride ¶ added in v0.5.0
func (*Response) HeaderXRealIP ¶ added in v0.5.0
func (*Response) HeaderXRequestID ¶ added in v0.5.0
func (*Response) HeaderXUrlScheme ¶ added in v0.5.0
func (*Response) HeaderXXSSProtection ¶ added in v0.5.0
func (*Response) StatusAccepted ¶ added in v0.4.0
func (*Response) StatusAlreadyReported ¶ added in v0.4.0
func (*Response) StatusBadGateway ¶ added in v0.4.0
func (*Response) StatusBadRequest ¶ added in v0.4.0
func (*Response) StatusConflict ¶ added in v0.4.0
func (*Response) StatusContinue ¶ added in v0.4.0
func (*Response) StatusCreated ¶ added in v0.4.0
func (*Response) StatusExpectationFailed ¶ added in v0.4.0
func (*Response) StatusFailedDependency ¶ added in v0.4.0
func (*Response) StatusForbidden ¶ added in v0.4.0
func (*Response) StatusFound ¶ added in v0.4.0
func (*Response) StatusGatewayTimeout ¶ added in v0.4.0
func (*Response) StatusGone ¶ added in v0.4.0
func (*Response) StatusHTTPVersionNotSupported ¶ added in v0.4.0
func (*Response) StatusIMUsed ¶ added in v0.4.0
func (*Response) StatusInsufficientStorage ¶ added in v0.4.0
func (*Response) StatusInternalServerError ¶ added in v0.4.0
func (*Response) StatusLengthRequired ¶ added in v0.4.0
func (*Response) StatusLocked ¶ added in v0.4.0
func (*Response) StatusLoopDetected ¶ added in v0.4.0
func (*Response) StatusMethodNotAllowed ¶ added in v0.4.0
func (*Response) StatusMovedPermanently ¶ added in v0.4.0
func (*Response) StatusMultiStatus ¶ added in v0.4.0
func (*Response) StatusMultipleChoices ¶ added in v0.4.0
func (*Response) StatusNetworkAuthenticationRequired ¶ added in v0.4.0
func (*Response) StatusNoContent ¶ added in v0.4.0
func (*Response) StatusNonAuthoritativeInfo ¶ added in v0.4.0
func (*Response) StatusNotAcceptable ¶ added in v0.4.0
func (*Response) StatusNotExtended ¶ added in v0.4.0
func (*Response) StatusNotFound ¶ added in v0.4.0
func (*Response) StatusNotImplemented ¶ added in v0.4.0
func (*Response) StatusNotModified ¶ added in v0.4.0
func (*Response) StatusPartialContent ¶ added in v0.4.0
func (*Response) StatusPaymentRequired ¶ added in v0.4.0
func (*Response) StatusPermanentRedirect ¶ added in v0.4.0
func (*Response) StatusPreconditionFailed ¶ added in v0.4.0
func (*Response) StatusPreconditionRequired ¶ added in v0.4.0
func (*Response) StatusProcessing ¶ added in v0.4.0
func (*Response) StatusProxyAuthRequired ¶ added in v0.4.0
func (*Response) StatusRequestEntityTooLarge ¶ added in v0.4.0
func (*Response) StatusRequestHeaderFieldsTooLarge ¶ added in v0.4.0
func (*Response) StatusRequestTimeout ¶ added in v0.4.0
func (*Response) StatusRequestURITooLong ¶ added in v0.4.0
func (*Response) StatusRequestedRangeNotSatisfiable ¶ added in v0.4.0
func (*Response) StatusResetContent ¶ added in v0.4.0
func (*Response) StatusSeeOther ¶ added in v0.4.0
func (*Response) StatusServiceUnavailable ¶ added in v0.4.0
func (*Response) StatusSwitchingProtocols ¶ added in v0.4.0
func (*Response) StatusTeapot ¶ added in v0.4.0
func (*Response) StatusTemporaryRedirect ¶ added in v0.4.0
func (*Response) StatusTooManyRequests ¶ added in v0.4.0
func (*Response) StatusUnauthorized ¶ added in v0.4.0
func (*Response) StatusUnavailableForLegalReasons ¶ added in v0.4.0
func (*Response) StatusUnprocessableEntity ¶ added in v0.4.0
func (*Response) StatusUnsupportedMediaType ¶ added in v0.4.0
func (*Response) StatusUpgradeRequired ¶ added in v0.4.0
func (*Response) StatusUseProxy ¶ added in v0.4.0
func (*Response) StatusVariantAlsoNegotiates ¶ added in v0.4.0
Click to show internal directories.
Click to hide internal directories.