Documentation
¶
Index ¶
- Variables
- func ConfigureHeader(req Request, key, value string, override bool) error
- func ReadJSON[T any](rc io.ReadCloser) (res T, err error)
- func ReadStream[T any](rc io.ReadCloser, factory StreamFactory[T], fn func(T) bool) (err error)
- func ReadStreamChan[T any](rc io.ReadCloser, factory StreamFactory[T], out chan<- T) (err error)
- type Call
- func (c *Call[T]) Call(ctx context.Context, e *Endpoint) (err error)
- func (c *Call[T]) Request(opts ...ReqOption) *Call[T]
- func (c *Call[T]) Response(opts ...ResOption) *Call[T]
- func (c *Call[T]) WithAssert(fn func(req Response) error) *Call[T]
- func (c *Call[T]) WithExpectedStatusCodes(states ...int) *Call[T]
- func (c *Call[T]) WithHeader(key, value string, override bool) *Call[T]
- func (c *Call[T]) WithHeaderFunc(fn func() (key, value string, override bool)) *Call[T]
- func (c *Call[T]) WithIgnoreBody() *Call[T]
- func (c *Call[T]) WithJSON() *Call[T]
- func (c *Call[T]) WithJSONEachRow(fn func(T) bool) *Call[T]
- func (c *Call[T]) WithJSONEachRowChan(out chan<- T) *Call[T]
- func (c *Call[T]) WithMethod(method string) *Call[T]
- func (c *Call[T]) WithRawBody(payload []byte) *Call[T]
- func (c *Call[T]) WithReadBody() *Call[T]
- func (c *Call[T]) WithStream(factory StreamFactory[T], fn func(T) bool) *Call[T]
- func (c *Call[T]) WithStreamChan(factory StreamFactory[T], ch chan<- T) *Call[T]
- func (c *Call[T]) WithURI(raw string) *Call[T]
- func (c *Call[T]) WithURL(raw string) *Call[T]
- type CallResOption
- type CallResOptionFunc
- func WithAssertion[T any](fn func(res Response) error) CallResOptionFunc[T]
- func WithCloseBody[T any]() CallResOptionFunc[T]
- func WithExpectedStatusCodes[T any](states ...int) CallResOptionFunc[T]
- func WithIgnoredBody[T any]() CallResOptionFunc[T]
- func WithJSON[T any]() CallResOptionFunc[T]
- func WithRawBody[T any]() CallResOptionFunc[T]
- func WithStream[T any](factory StreamFactory[T], fn func(T) bool) CallResOptionFunc[T]
- func WithStreamChan[T any](factory StreamFactory[T], out chan<- T) CallResOptionFunc[T]
- type Endpoint
- type FastHttpHttpClientAdapter
- type JSONEachRowStream
- type MockEndpoint
- type MockHttpClientAdapter
- type NativeHttpClientAdapter
- type ReqOption
- type ReqOptionFunc
- type Request
- type ResOption
- type ResOptionFunc
- type Response
- type Stream
- type StreamFactory
- type StreamFactoryFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAssertion = errors.New("assertion was unmet") ErrUnexpectedStatusCode = errors.Wrap(ErrAssertion, "unexpected status code") )
Functions ¶
func ReadStream ¶
func ReadStream[T any](rc io.ReadCloser, factory StreamFactory[T], fn func(T) bool) (err error)
func ReadStreamChan ¶
func ReadStreamChan[T any](rc io.ReadCloser, factory StreamFactory[T], out chan<- T) (err error)
Types ¶
type Call ¶
type Call[T any] struct { Req Request Res Response BodyRaw []byte BodyParsed T ReqBodyRaw []byte // contains filtered or unexported fields }
func (*Call[T]) WithAssert ¶
func (*Call[T]) WithExpectedStatusCodes ¶
func (c *Call[T]) WithExpectedStatusCodes(states ...int) *Call[T]
func (*Call[T]) WithHeader ¶
func (*Call[T]) WithHeaderFunc ¶
func (*Call[T]) WithIgnoreBody ¶
func (c *Call[T]) WithIgnoreBody() *Call[T]
func (*Call[T]) WithJSONEachRow ¶
func (c *Call[T]) WithJSONEachRow(fn func(T) bool) *Call[T]
func (*Call[T]) WithJSONEachRowChan ¶
func (c *Call[T]) WithJSONEachRowChan(out chan<- T) *Call[T]
func (*Call[T]) WithMethod ¶
func (c *Call[T]) WithMethod(method string) *Call[T]
func (*Call[T]) WithRawBody ¶
func (c *Call[T]) WithRawBody(payload []byte) *Call[T]
func (*Call[T]) WithReadBody ¶
func (c *Call[T]) WithReadBody() *Call[T]
func (*Call[T]) WithStream ¶
func (c *Call[T]) WithStream(factory StreamFactory[T], fn func(T) bool) *Call[T]
func (*Call[T]) WithStreamChan ¶
func (c *Call[T]) WithStreamChan(factory StreamFactory[T], ch chan<- T) *Call[T]
type CallResOption ¶
type CallResOptionFunc ¶
func WithAssertion ¶
func WithCloseBody ¶
func WithCloseBody[T any]() CallResOptionFunc[T]
func WithExpectedStatusCodes ¶
func WithIgnoredBody ¶
func WithIgnoredBody[T any]() CallResOptionFunc[T]
func WithRawBody ¶
func WithRawBody[T any]() CallResOptionFunc[T]
func WithStream ¶
func WithStreamChan ¶
func WithStreamChan[T any](factory StreamFactory[T], out chan<- T) CallResOptionFunc[T]
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
func NewEndpoint ¶
type FastHttpHttpClientAdapter ¶
type FastHttpHttpClientAdapter struct {
// contains filtered or unexported fields
}
func NewDefaultFastHttpHttpClientAdapter ¶
func NewDefaultFastHttpHttpClientAdapter() *FastHttpHttpClientAdapter
func NewFastHttpHttpClientAdapter ¶
func NewFastHttpHttpClientAdapter(cli *fasthttp.Client) *FastHttpHttpClientAdapter
func (*FastHttpHttpClientAdapter) Request ¶
func (a *FastHttpHttpClientAdapter) Request() (Request, error)
type JSONEachRowStream ¶
type JSONEachRowStream[T any] struct { // contains filtered or unexported fields }
func (*JSONEachRowStream[T]) Data ¶
func (s *JSONEachRowStream[T]) Data() T
func (*JSONEachRowStream[T]) Err ¶
func (s *JSONEachRowStream[T]) Err() error
type MockEndpoint ¶
type MockEndpoint struct {
// contains filtered or unexported fields
}
type MockHttpClientAdapter ¶
type MockHttpClientAdapter struct{}
func NewMockHttpClientAdapter ¶
func NewMockHttpClientAdapter() *MockHttpClientAdapter
func (*MockHttpClientAdapter) Request ¶
func (a *MockHttpClientAdapter) Request() (Request, error)
type NativeHttpClientAdapter ¶
type NativeHttpClientAdapter struct {
// contains filtered or unexported fields
}
func NewDefaultNativeHttpClientAdapter ¶
func NewDefaultNativeHttpClientAdapter() *NativeHttpClientAdapter
func NewNativeHttpClientAdapter ¶
func NewNativeHttpClientAdapter(cli *http.Client) *NativeHttpClientAdapter
func (*NativeHttpClientAdapter) Request ¶
func (a *NativeHttpClientAdapter) Request() (Request, error)
type ReqOptionFunc ¶
func (ReqOptionFunc) Configure ¶
func (f ReqOptionFunc) Configure(req Request) error
type ResOption ¶
func WithResMock ¶
type ResOptionFunc ¶
func (ResOptionFunc) Parse ¶
func (f ResOptionFunc) Parse(res Response) error
type Response ¶
type Response interface {
Status() int
StatusText() string
Body() io.ReadCloser
SetBody(rc io.ReadCloser)
SetStatus(status int)
}
type StreamFactory ¶
func NewJSONEachRowStreamFactory ¶
func NewJSONEachRowStreamFactory[T any]() StreamFactory[T]
Source Files
¶
Click to show internal directories.
Click to hide internal directories.