Documentation ΒΆ
Index ΒΆ
- func BuildResponse(response *http.Response) *httpRes
- func GenCurlCommand(req *http.Request, httpCookiejar http.CookieJar) (curlString string)
- type AssertError
- type ContentType
- type ExpectTestType
- type HeaderType
- type ReqItem
- type RequestTeser
- func (r *RequestTeser) AddCookieKV(name, value string) *RequestTeser
- func (r *RequestTeser) AddCookies(cookies []*http.Cookie) *RequestTeser
- func (r *RequestTeser) AddFile(fieldname, path string) *RequestTeser
- func (r *RequestTeser) AddFileHeader(fieldname, filename string, content []byte) *RequestTeser
- func (r *RequestTeser) AssertBodyContains(substr string) *RequestTeser
- func (r *RequestTeser) AssertBodyJqEqual(expr string, expectedVal string) *RequestTeser
- func (r *RequestTeser) AssertHeaderContains(prop HeaderType, substr string) *RequestTeser
- func (r *RequestTeser) AssertHeaderEqual(prop HeaderType, val string) *RequestTeser
- func (r *RequestTeser) AssertRules()
- func (r *RequestTeser) AssertStatusBetween(start, end int) *RequestTeser
- func (r *RequestTeser) CreateGinContext() (ctx *gin.Context)
- func (r *RequestTeser) EnableTrace(ctx context.Context) *RequestTeser
- func (r *RequestTeser) FromCurl(curl string)
- func (r *RequestTeser) GenCurlCommand() (curl string, err error)
- func (rb *RequestTeser) GenRequest() (*http.Request, error)
- func (r *RequestTeser) GetRawreq() *http.Request
- func (r *RequestTeser) SetAuthBasic(username, password string) *RequestTeser
- func (r *RequestTeser) SetAuthBearer(token string) *RequestTeser
- func (r *RequestTeser) SetBody(body []byte) *RequestTeser
- func (r *RequestTeser) SetContentType(ct ContentType) *RequestTeser
- func (r *RequestTeser) SetCtx(ctx context.Context) *RequestTeser
- func (r *RequestTeser) SetFormData(data map[string]string) *RequestTeser
- func (r *RequestTeser) SetFormDataFromValues(data url.Values) *RequestTeser
- func (r *RequestTeser) SetHeader(key, value string) *RequestTeser
- func (r *RequestTeser) SetHost(host string) *RequestTeser
- func (r *RequestTeser) SetIsMultiPart(b bool) *RequestTeser
- func (r *RequestTeser) SetJson(data any) *RequestTeser
- func (r *RequestTeser) SetQueryParam(param, value string) *RequestTeser
- func (r *RequestTeser) SetQueryParamTpl(k, jqExpr string) *RequestTeser
- func (r *RequestTeser) SetQueryParams(params map[string]string) *RequestTeser
- func (r *RequestTeser) SetQueryParamsFromValues(params url.Values) *RequestTeser
- func (r *RequestTeser) SetQueryParamsTpl(params map[string]string) *RequestTeser
- func (r *RequestTeser) SetReq(method string, url string) *RequestTeser
- func (r *RequestTeser) SetResponse(resp *httptest.ResponseRecorder) *RequestTeser
- func (r *RequestTeser) SetUrl(url string) *RequestTeser
- func (r *RequestTeser) Sync()
- func (r *RequestTeser) Test(name string, f func(*RequestTeser))
- type RequestTpl
- type TestRule
- type TraceInfo
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func BuildResponse ΒΆ
Types ΒΆ
type AssertError ΒΆ
func (*AssertError) Error ΒΆ
func (e *AssertError) Error() string
type ContentType ΒΆ
type ContentType string
const ( ContentTypeNone ContentType = "" ContentTypeFormEncode ContentType = "application/x-www-form-urlencoded" ContentTypeFormData ContentType = "multipart/form-data" ContentTypeJson ContentType = "application/json" ContentTypePlain ContentType = "text/plain" )
type ExpectTestType ΒΆ
type ExpectTestType string
const ( ExpectTestHeaderEqual ExpectTestType = "header-equal" ExpectTestHeaderContains ExpectTestType = "header-contains" ExpectTestStatusBetween ExpectTestType = "status-between" ExpectTestBodyEqual ExpectTestType = "body-equal" ExpectTestBodyContains ExpectTestType = "body-contains" ExpectTestBodyJqEqual ExpectTestType = "body-jq-equal" ExpectTestBodyJqContains ExpectTestType = "body-jq-contains" )
type HeaderType ΒΆ
type HeaderType string
const ( HeaderContentType HeaderType = "Content-Type" HeaderAuthorization HeaderType = "Authorization" HeaderCookie HeaderType = "Cookie" )
type ReqItem ΒΆ
type ReqItem struct { Name string Url string Method string // QueryParam url.Values // FormData url.Values IsMultiPart bool InputHeaders map[string]string InputParams map[string]string InputFormData map[string]string InputBody string Json any OutputHeaders map[string]string OutputBody string // request ζ¨‘ζΏ Tpl *RequestTpl Testrules []TestRule }
type RequestTeser ΒΆ
type RequestTeser struct { // Response Response *http.Response // contains filtered or unexported fields }
func (*RequestTeser) AddCookieKV ΒΆ
func (r *RequestTeser) AddCookieKV(name, value string) *RequestTeser
func (*RequestTeser) AddCookies ΒΆ
func (r *RequestTeser) AddCookies(cookies []*http.Cookie) *RequestTeser
func (*RequestTeser) AddFile ΒΆ
func (r *RequestTeser) AddFile(fieldname, path string) *RequestTeser
************* params ********************* ************* file *********************
func (*RequestTeser) AddFileHeader ΒΆ
func (r *RequestTeser) AddFileHeader(fieldname, filename string, content []byte) *RequestTeser
func (*RequestTeser) AssertBodyContains ΒΆ
func (r *RequestTeser) AssertBodyContains(substr string) *RequestTeser
func (*RequestTeser) AssertBodyJqEqual ΒΆ
func (r *RequestTeser) AssertBodyJqEqual(expr string, expectedVal string) *RequestTeser
func (*RequestTeser) AssertHeaderContains ΒΆ
func (r *RequestTeser) AssertHeaderContains(prop HeaderType, substr string) *RequestTeser
ExpectHeaderContains("Cookie", "session=123")
func (*RequestTeser) AssertHeaderEqual ΒΆ
func (r *RequestTeser) AssertHeaderEqual(prop HeaderType, val string) *RequestTeser
func (*RequestTeser) AssertRules ΒΆ
func (r *RequestTeser) AssertRules()
func (*RequestTeser) AssertStatusBetween ΒΆ
func (r *RequestTeser) AssertStatusBetween(start, end int) *RequestTeser
func (*RequestTeser) CreateGinContext ΒΆ
func (r *RequestTeser) CreateGinContext() (ctx *gin.Context)
func (*RequestTeser) EnableTrace ΒΆ
func (r *RequestTeser) EnableTrace(ctx context.Context) *RequestTeser
func (*RequestTeser) FromCurl ΒΆ
func (r *RequestTeser) FromCurl(curl string)
func (*RequestTeser) GenCurlCommand ΒΆ
func (r *RequestTeser) GenCurlCommand() (curl string, err error)
func (*RequestTeser) GenRequest ΒΆ
func (rb *RequestTeser) GenRequest() (*http.Request, error)
Generate a http.Request
func (*RequestTeser) GetRawreq ΒΆ
func (r *RequestTeser) GetRawreq() *http.Request
************* utils *********************
func (*RequestTeser) SetAuthBasic ΒΆ
func (r *RequestTeser) SetAuthBasic(username, password string) *RequestTeser
func (*RequestTeser) SetAuthBearer ΒΆ
func (r *RequestTeser) SetAuthBearer(token string) *RequestTeser
func (*RequestTeser) SetBody ΒΆ
func (r *RequestTeser) SetBody(body []byte) *RequestTeser
************* body(bytes) *********************
func (*RequestTeser) SetContentType ΒΆ
func (r *RequestTeser) SetContentType(ct ContentType) *RequestTeser
func (*RequestTeser) SetCtx ΒΆ
func (r *RequestTeser) SetCtx(ctx context.Context) *RequestTeser
func (*RequestTeser) SetFormData ΒΆ
func (r *RequestTeser) SetFormData(data map[string]string) *RequestTeser
func (*RequestTeser) SetFormDataFromValues ΒΆ
func (r *RequestTeser) SetFormDataFromValues(data url.Values) *RequestTeser
SetFormDataFromValues method appends multiple form parameters with multi-value
SetFormDataFromValues(url.Values{"words": []string{"book", "glass", "pencil"},})
func (*RequestTeser) SetHeader ΒΆ
func (r *RequestTeser) SetHeader(key, value string) *RequestTeser
*****************header ************************
func (*RequestTeser) SetHost ΒΆ
func (r *RequestTeser) SetHost(host string) *RequestTeser
*****************host************************
func (*RequestTeser) SetIsMultiPart ΒΆ
func (r *RequestTeser) SetIsMultiPart(b bool) *RequestTeser
************* body(form) ********************* Set Form data(encode or multipart)
func (*RequestTeser) SetJson ΒΆ
func (r *RequestTeser) SetJson(data any) *RequestTeser
************* body(json) *********************
func (*RequestTeser) SetQueryParam ΒΆ
func (r *RequestTeser) SetQueryParam(param, value string) *RequestTeser
func (*RequestTeser) SetQueryParamTpl ΒΆ
func (r *RequestTeser) SetQueryParamTpl(k, jqExpr string) *RequestTeser
func (*RequestTeser) SetQueryParams ΒΆ
func (r *RequestTeser) SetQueryParams(params map[string]string) *RequestTeser
************* params *********************
func (*RequestTeser) SetQueryParamsFromValues ΒΆ
func (r *RequestTeser) SetQueryParamsFromValues(params url.Values) *RequestTeser
func (*RequestTeser) SetQueryParamsTpl ΒΆ
func (r *RequestTeser) SetQueryParamsTpl(params map[string]string) *RequestTeser
func (*RequestTeser) SetReq ΒΆ
func (r *RequestTeser) SetReq(method string, url string) *RequestTeser
func (*RequestTeser) SetResponse ΒΆ
func (r *RequestTeser) SetResponse(resp *httptest.ResponseRecorder) *RequestTeser
func (*RequestTeser) SetUrl ΒΆ
func (r *RequestTeser) SetUrl(url string) *RequestTeser
func (*RequestTeser) Sync ΒΆ
func (r *RequestTeser) Sync()
func (*RequestTeser) Test ΒΆ
func (r *RequestTeser) Test(name string, f func(*RequestTeser))
type RequestTpl ΒΆ
type TestRule ΒΆ
type TestRule struct { AssertType ExpectTestType PropOrExpr string ExpectedVal string ExpectedBetweenInt [2]int }
type TraceInfo ΒΆ
type TraceInfo struct { // DNSLookup is a duration that transport took to perform // DNS lookup. DNSLookup time.Duration // ConnTime is a duration that took to obtain a successful connection. ConnTime time.Duration // TCPConnTime is a duration that took to obtain the TCP connection. TCPConnTime time.Duration // TLSHandshake is a duration that TLS handshake took place. TLSHandshake time.Duration // ServerTime is a duration that server took to respond first byte. ServerTime time.Duration // ResponseTime is a duration since first response byte from server to // request completion. ResponseTime time.Duration // TotalTime is a duration that total request took end-to-end. TotalTime time.Duration // IsConnReused is whether this connection has been previously // used for another HTTP request. IsConnReused bool // IsConnWasIdle is whether this connection was obtained from an // idle pool. IsConnWasIdle bool // ConnIdleTime is a duration how long the connection was previously // idle, if IsConnWasIdle is true. ConnIdleTime time.Duration // RequestAttempt is to represent the request attempt made during a Resty // request execution flow, including retry count. RequestAttempt int // RemoteAddr returns the remote network address. RemoteAddr net.Addr }
TraceInfo struct is used provide request trace info such as DNS lookup duration, Connection obtain duration, Server processing duration, etc.
Since v2.0.0
Source Files ΒΆ
Directories ΒΆ
Path | Synopsis |
---|---|
Package shellescape provides the shellescape.Quote to escape arbitrary strings for a safe use as command line arguments in the most common POSIX shells.
|
Package shellescape provides the shellescape.Quote to escape arbitrary strings for a safe use as command line arguments in the most common POSIX shells. |