Documentation
¶
Index ¶
- type Config
- type Factory
- func (r *Factory) AllowStrayRequests(patterns []string) client.Factory
- func (r *Factory) AssertNotSent(assertion func(client.Request) bool) bool
- func (r *Factory) AssertNothingSent() bool
- func (r *Factory) AssertSent(assertion func(client.Request) bool) bool
- func (r *Factory) AssertSentCount(count int) bool
- func (r *Factory) Client(names ...string) client.Request
- func (r *Factory) Fake(mocks map[string]any) client.Factory
- func (r *Factory) PreventStrayRequests() client.Factory
- func (r *Factory) Reset()
- func (r *Factory) Response() client.FakeResponse
- func (r *Factory) Sequence() client.FakeSequence
- type FactoryConfig
- type FakeResponse
- func (r *FakeResponse) File(status int, path string) client.Response
- func (r *FakeResponse) Json(status int, data any) client.Response
- func (r *FakeResponse) Make(status int, body string, header http.Header) client.Response
- func (r *FakeResponse) OK() client.Response
- func (r *FakeResponse) Status(status int) client.Response
- func (r *FakeResponse) String(status int, body string) client.Response
- type FakeRule
- type FakeSequence
- func (r *FakeSequence) Push(response client.Response, count ...int) client.FakeSequence
- func (r *FakeSequence) PushStatus(status int, count ...int) client.FakeSequence
- func (r *FakeSequence) PushString(status int, body string, count ...int) client.FakeSequence
- func (r *FakeSequence) WhenEmpty(response client.Response) client.FakeSequence
- type FakeState
- func (r *FakeState) AllowStrayRequests(patterns []string)
- func (r *FakeState) AssertSent(f func(client.Request) bool) bool
- func (r *FakeState) AssertSentCount(count int) bool
- func (r *FakeState) Match(req *http.Request, name string) func(client.Request) client.Response
- func (r *FakeState) PreventStrayRequests()
- func (r *FakeState) Record(req client.Request)
- func (r *FakeState) ShouldPreventStray(url string) bool
- type FakeTransport
- type Request
- func (r *Request) Accept(contentType string) client.Request
- func (r *Request) AcceptJSON() client.Request
- func (r *Request) AsForm() client.Request
- func (r *Request) BaseUrl(url string) client.Request
- func (r *Request) Body() string
- func (r *Request) ClientName() string
- func (r *Request) Clone() client.Request
- func (r *Request) Delete(uri string, body io.Reader) (client.Response, error)
- func (r *Request) FlushHeaders() client.Request
- func (r *Request) Get(uri string) (client.Response, error)
- func (r *Request) Head(uri string) (client.Response, error)
- func (r *Request) Header(key string) string
- func (r *Request) Headers() http.Header
- func (r *Request) HttpClient() *http.Client
- func (r *Request) Input(key string) any
- func (r *Request) Method() string
- func (r *Request) Options(uri string) (client.Response, error)
- func (r *Request) Patch(uri string, body io.Reader) (client.Response, error)
- func (r *Request) Post(uri string, body io.Reader) (client.Response, error)
- func (r *Request) Put(uri string, body io.Reader) (client.Response, error)
- func (r *Request) ReplaceHeaders(headers map[string]string) client.Request
- func (r *Request) Url() string
- func (r *Request) WithBasicAuth(username, password string) client.Request
- func (r *Request) WithContext(ctx context.Context) client.Request
- func (r *Request) WithCookie(cookie *http.Cookie) client.Request
- func (r *Request) WithCookies(cookies []*http.Cookie) client.Request
- func (r *Request) WithHeader(key, value string) client.Request
- func (r *Request) WithHeaders(headers map[string]string) client.Request
- func (r *Request) WithQueryParameter(key, value string) client.Request
- func (r *Request) WithQueryParameters(params map[string]string) client.Request
- func (r *Request) WithQueryString(query string) client.Request
- func (r *Request) WithToken(token string, ttype ...string) client.Request
- func (r *Request) WithUrlParameter(key, value string) client.Request
- func (r *Request) WithUrlParameters(params map[string]string) client.Request
- func (r *Request) WithoutHeader(key string) client.Request
- func (r *Request) WithoutToken() client.Request
- type Response
- func (r *Response) Accepted() bool
- func (r *Response) BadRequest() bool
- func (r *Response) Bind(value any) error
- func (r *Response) Body() (string, error)
- func (r *Response) ClientError() bool
- func (r *Response) Conflict() bool
- func (r *Response) Cookie(name string) *http.Cookie
- func (r *Response) Cookies() []*http.Cookie
- func (r *Response) Created() bool
- func (r *Response) Failed() bool
- func (r *Response) Forbidden() bool
- func (r *Response) Found() bool
- func (r *Response) Header(name string) string
- func (r *Response) Headers() http.Header
- func (r *Response) Json() (map[string]any, error)
- func (r *Response) MovedPermanently() bool
- func (r *Response) NoContent() bool
- func (r *Response) NotFound() bool
- func (r *Response) OK() bool
- func (r *Response) Origin() *http.Response
- func (r *Response) PaymentRequired() bool
- func (r *Response) Redirect() bool
- func (r *Response) RequestTimeout() bool
- func (r *Response) ServerError() bool
- func (r *Response) Status() int
- func (r *Response) Stream() (io.ReadCloser, error)
- func (r *Response) Successful() bool
- func (r *Response) TooManyRequests() bool
- func (r *Response) Unauthorized() bool
- func (r *Response) UnprocessableEntity() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v1.17.0
type Config struct {
// BaseUrl is the prefix for all requests made by this client.
// Example: "https://goravel.dev"
BaseUrl string `json:"base_url"`
// Timeout specifies the time limit for requests made by this Client.
// The timeout includes connection time, any redirects, and reading the response body.
// A Timeout of zero means no timeout (not recommended).
Timeout time.Duration `json:"timeout"`
// MaxIdleConns controls the maximum number of idle (keep-alive) connections across all hosts.
// Increasing this helps performance when making many requests to distinct hosts.
MaxIdleConns int `json:"max_idle_conns"`
// MaxIdleConnsPerHost controls the maximum number of idle (keep-alive) connections
// to keep per-host. This is the most critical setting for high-throughput clients
// talking to a single backend service.
MaxIdleConnsPerHost int `json:"max_idle_conns_per_host"`
// MaxConnsPerHost limits the total number of connections (active + idle) per host.
// Zero means no limit.
MaxConnsPerHost int `json:"max_conns_per_host"`
// IdleConnTimeout is the maximum amount of time an idle (keep-alive) connection
// will remain idle before closing itself.
IdleConnTimeout time.Duration `json:"idle_conn_timeout"`
}
type Factory ¶ added in v1.17.0
func NewFactory ¶ added in v1.17.0
func NewFactory(config *FactoryConfig, json foundation.Json) (*Factory, error)
func (*Factory) AllowStrayRequests ¶ added in v1.17.0
func (*Factory) AssertNotSent ¶ added in v1.17.0
func (*Factory) AssertNothingSent ¶ added in v1.17.0
func (*Factory) AssertSent ¶ added in v1.17.0
func (*Factory) AssertSentCount ¶ added in v1.17.0
func (*Factory) PreventStrayRequests ¶ added in v1.17.0
func (*Factory) Response ¶ added in v1.17.0
func (r *Factory) Response() client.FakeResponse
func (*Factory) Sequence ¶ added in v1.17.0
func (r *Factory) Sequence() client.FakeSequence
type FactoryConfig ¶ added in v1.17.0
type FakeResponse ¶ added in v1.17.0
type FakeResponse struct {
// contains filtered or unexported fields
}
func NewFakeResponse ¶ added in v1.17.0
func NewFakeResponse(json foundation.Json) *FakeResponse
func (*FakeResponse) File ¶ added in v1.17.0
func (r *FakeResponse) File(status int, path string) client.Response
func (*FakeResponse) Json ¶ added in v1.17.0
func (r *FakeResponse) Json(status int, data any) client.Response
func (*FakeResponse) OK ¶ added in v1.17.0
func (r *FakeResponse) OK() client.Response
type FakeRule ¶ added in v1.17.0
type FakeRule struct {
// contains filtered or unexported fields
}
func NewFakeRule ¶ added in v1.17.0
type FakeSequence ¶ added in v1.17.0
type FakeSequence struct {
// contains filtered or unexported fields
}
func NewFakeSequence ¶ added in v1.17.0
func NewFakeSequence(json foundation.Json) *FakeSequence
func (*FakeSequence) Push ¶ added in v1.17.0
func (r *FakeSequence) Push(response client.Response, count ...int) client.FakeSequence
func (*FakeSequence) PushStatus ¶ added in v1.17.0
func (r *FakeSequence) PushStatus(status int, count ...int) client.FakeSequence
func (*FakeSequence) PushString ¶ added in v1.17.0
func (r *FakeSequence) PushString(status int, body string, count ...int) client.FakeSequence
func (*FakeSequence) WhenEmpty ¶ added in v1.17.0
func (r *FakeSequence) WhenEmpty(response client.Response) client.FakeSequence
type FakeState ¶ added in v1.17.0
type FakeState struct {
// contains filtered or unexported fields
}
func NewFakeState ¶ added in v1.17.0
func NewFakeState(json foundation.Json, mocks map[string]any) *FakeState
func (*FakeState) AllowStrayRequests ¶ added in v1.17.0
func (*FakeState) AssertSent ¶ added in v1.17.0
func (*FakeState) AssertSentCount ¶ added in v1.17.0
func (*FakeState) PreventStrayRequests ¶ added in v1.17.0
func (r *FakeState) PreventStrayRequests()
func (*FakeState) ShouldPreventStray ¶ added in v1.17.0
type FakeTransport ¶ added in v1.17.0
type FakeTransport struct {
// contains filtered or unexported fields
}
func NewFakeTransport ¶ added in v1.17.0
func NewFakeTransport(state *FakeState, base http.RoundTripper, json foundation.Json) *FakeTransport
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func (*Request) AcceptJSON ¶
func (*Request) ClientName ¶ added in v1.17.0
func (*Request) FlushHeaders ¶
func (*Request) HttpClient ¶ added in v1.17.0
func (*Request) ReplaceHeaders ¶
func (*Request) WithBasicAuth ¶
func (*Request) WithHeaders ¶
func (*Request) WithQueryParameter ¶
func (*Request) WithQueryParameters ¶
func (*Request) WithUrlParameter ¶
func (*Request) WithUrlParameters ¶
func (*Request) WithoutToken ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func NewResponse ¶
func NewResponse(response *http.Response, json foundation.Json) *Response
func (*Response) BadRequest ¶
func (*Response) ClientError ¶
func (*Response) MovedPermanently ¶
func (*Response) PaymentRequired ¶
func (*Response) RequestTimeout ¶
func (*Response) ServerError ¶
func (*Response) Successful ¶
func (*Response) TooManyRequests ¶
func (*Response) Unauthorized ¶
func (*Response) UnprocessableEntity ¶
Click to show internal directories.
Click to hide internal directories.