Documentation
¶
Index ¶
- Variables
- func B2S(data []byte) string
- func BtsIsset(bts []byte) bool
- func BytesEquals(a, b []byte) bool
- func ConfigureHeader(req Request, key, value string, override bool) error
- func CreateAuthorizationHeader(kind authHeaderKind, user, pass string) (string, error)
- func EncodeBody(payload any, contentType ContentType) (bts []byte, err error)
- func EncodeStream[T any](ctx context.Context, r rangeable[T], req Request, encoder codec.Encoder, ...) (err 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)
- func S2B(s string) (bts []byte)
- func StrIsset(s string) bool
- type CSVStream
- type Call
- func (c *Call[T]) Call(ctx context.Context) (err error)
- func (c *Call[T]) CallEndpoint(ctx context.Context, e *Endpoint) (err error)
- func (c *Call[T]) Log(w io.Writer)
- 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]) WithBasicAuth(user, pass string) *Call[T]
- func (c *Call[T]) WithBody(payload any) *Call[T]
- func (c *Call[T]) WithBodyStream(rc io.ReadWriteCloser, bodySize int) *Call[T]
- func (c *Call[T]) WithContentLength(length int) *Call[T]
- func (c *Call[T]) WithContentType(ct ContentType) *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]) WithIgnoreResponseBody() *Call[T]
- func (c *Call[T]) WithLogger(l logger) *Call[T]
- func (c *Call[T]) WithMethod(method string) *Call[T]
- func (c *Call[T]) WithParseCSV(ignoreLines int, parser csvparser.Parser[T], fn func(T) bool) *Call[T]
- func (c *Call[T]) WithParseJSON() *Call[T]
- func (c *Call[T]) WithParseJSONEachRow(fn func(T) bool) *Call[T]
- func (c *Call[T]) WithParseJSONEachRowChan(out chan<- T) *Call[T]
- func (c *Call[T]) WithParseStream(factory StreamFactory[T], fn func(T) bool) *Call[T]
- func (c *Call[T]) WithParseStreamChan(factory StreamFactory[T], ch chan<- T) *Call[T]
- func (c *Call[T]) WithRawBody(payload []byte) *Call[T]
- func (c *Call[T]) WithReadBody() *Call[T]
- func (c *Call[T]) WithRequestSniffed(fn func([]byte, error)) *Call[T]
- func (c *Call[T]) WithRequestStreamBody(opt StreamCallReqOptionFunc[T]) *Call[T]
- func (c *Call[T]) WithURI(raw string) *Call[T]
- func (c *Call[T]) WithURL(raw string) *Call[T]
- type CallReqOption
- type CallReqOptionFunc
- func WithBasicAuth[T any](user, pass string) CallReqOptionFunc[T]
- func WithBody[T any](payload any) CallReqOptionFunc[T]
- func WithBodyStream[T any](rc io.ReadWriteCloser, bodySize int) CallReqOptionFunc[T]
- func WithContentType[T any](ct ContentType) CallReqOptionFunc[T]
- func WithHeader[T any](k, v string, override bool) CallReqOptionFunc[T]
- func WithHeaderFunc[T any](fn func() (string, string, bool)) CallReqOptionFunc[T]
- func WithMethod[T any](method string) CallReqOptionFunc[T]
- func WithRawBody[T any](payload []byte) CallReqOptionFunc[T]
- func WithRequestSniffer[T any](fn func([]byte, error)) CallReqOptionFunc[T]
- func WithURI[T any](raw string) CallReqOptionFunc[T]
- func WithURL[T any](raw string) CallReqOptionFunc[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 WithParseBodyRaw[T any]() CallResOptionFunc[T]
- func WithParseJSON[T any]() CallResOptionFunc[T]
- func WithParseStream[T any](factory StreamFactory[T], fn func(T) bool) CallResOptionFunc[T]
- func WithParseStreamChan[T any](factory StreamFactory[T], out chan<- T) CallResOptionFunc[T]
- type Channel
- type Client
- type ContentType
- type Endpoint
- type FastHttpHttpClientAdapter
- type Header
- type JSONEachRowStream
- type MockEndpoint
- type MockHttpClientAdapter
- type NativeHttpClientAdapter
- type NewLineStream
- type ProxyStream
- type ReqOption
- type ReqOptionFunc
- type Request
- type ResOption
- type ResOptionFunc
- type Response
- type Slice
- type Stream
- type StreamCallReqOption
- type StreamCallReqOptionFunc
- type StreamFactory
- type StreamFactoryFunc
- type StreamFromReader
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAssertion = errors.New("assertion was unmet") ErrUnexpectedStatusCode = errors.Wrap(ErrAssertion, "unexpected status code") ErrInsufficientParams = errors.New("insufficient params") )
View Source
var (
ErrUnknownContentType = errors.New("unknown content type")
)
Functions ¶
func BytesEquals ¶ added in v0.3.0
func CreateAuthorizationHeader ¶ added in v0.5.0
func EncodeBody ¶ added in v0.2.0
func EncodeBody(payload any, contentType ContentType) (bts []byte, err error)
func EncodeStream ¶ added in v0.3.0
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 CSVStream ¶ added in v0.6.0
type CSVStream[T any] struct { // contains filtered or unexported fields }
type Call ¶
type Call[T any] struct { Req Request Res Response BodyRaw []byte BodyParsed T ReqContentType ContentType ReqBodyRaw []byte ReqIsStream bool ReqStreamWriter func(ctx context.Context, c *Call[T], res Request, wg *sync.WaitGroup) error ReqStreamSniffer func([]byte, error) ReqShouldSniff bool // contains filtered or unexported fields }
func (*Call[T]) CallEndpoint ¶ added in v0.2.0
func (*Call[T]) WithAssert ¶
func (*Call[T]) WithBasicAuth ¶ added in v0.5.0
func (c *Call[T]) WithBasicAuth(user, pass string) *Call[T]
func (*Call[T]) WithBodyStream ¶ added in v0.2.0
func (c *Call[T]) WithBodyStream(rc io.ReadWriteCloser, bodySize int) *Call[T]
WithBodyStream receives a stream of data to set on the request. Second parameter `bodySize` indicates the estimated content-length of this stream. Required when employing fasthttp http client.
func (*Call[T]) WithContentLength ¶ added in v0.2.0
func (c *Call[T]) WithContentLength(length int) *Call[T]
func (*Call[T]) WithContentType ¶ added in v0.2.0
func (c *Call[T]) WithContentType(ct ContentType) *Call[T]
func (*Call[T]) WithExpectedStatusCodes ¶
func (c *Call[T]) WithExpectedStatusCodes(states ...int) *Call[T]
func (*Call[T]) WithHeader ¶
func (*Call[T]) WithHeaderFunc ¶
func (*Call[T]) WithIgnoreResponseBody ¶ added in v0.3.0
func (c *Call[T]) WithIgnoreResponseBody() *Call[T]
func (*Call[T]) WithLogger ¶ added in v0.7.0
func (c *Call[T]) WithLogger(l logger) *Call[T]
func (*Call[T]) WithMethod ¶
func (c *Call[T]) WithMethod(method string) *Call[T]
func (*Call[T]) WithParseCSV ¶ added in v0.6.0
func (*Call[T]) WithParseJSON ¶ added in v0.2.0
func (c *Call[T]) WithParseJSON() *Call[T]
func (*Call[T]) WithParseJSONEachRow ¶ added in v0.3.0
func (c *Call[T]) WithParseJSONEachRow(fn func(T) bool) *Call[T]
func (*Call[T]) WithParseJSONEachRowChan ¶ added in v0.3.0
func (c *Call[T]) WithParseJSONEachRowChan(out chan<- T) *Call[T]
func (*Call[T]) WithParseStream ¶ added in v0.3.0
func (c *Call[T]) WithParseStream(factory StreamFactory[T], fn func(T) bool) *Call[T]
func (*Call[T]) WithParseStreamChan ¶ added in v0.3.0
func (c *Call[T]) WithParseStreamChan(factory StreamFactory[T], ch chan<- T) *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]) WithRequestSniffed ¶ added in v0.4.0
func (*Call[T]) WithRequestStreamBody ¶ added in v0.3.0
func (c *Call[T]) WithRequestStreamBody(opt StreamCallReqOptionFunc[T]) *Call[T]
type CallReqOption ¶ added in v0.3.0
type CallReqOptionFunc ¶ added in v0.2.0
func WithBasicAuth ¶ added in v0.5.0
func WithBodyStream ¶ added in v0.2.0
func WithBodyStream[T any](rc io.ReadWriteCloser, bodySize int) CallReqOptionFunc[T]
func WithContentType ¶ added in v0.2.0
func WithContentType[T any](ct ContentType) CallReqOptionFunc[T]
func WithHeader ¶ added in v0.2.0
func WithHeaderFunc ¶ added in v0.2.0
func WithMethod ¶ added in v0.2.0
func WithRawBody ¶
func WithRequestSniffer ¶ added in v0.4.0
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 WithParseBodyRaw ¶ added in v0.2.0
func WithParseBodyRaw[T any]() CallResOptionFunc[T]
func WithParseJSON ¶ added in v0.3.0
func WithParseJSON[T any]() CallResOptionFunc[T]
func WithParseStream ¶ added in v0.3.0
func WithParseStreamChan ¶ added in v0.3.0
func WithParseStreamChan[T any](factory StreamFactory[T], out chan<- T) CallResOptionFunc[T]
type ContentType ¶ added in v0.2.0
type ContentType string
var ( ContentTypeJSON ContentType = "application/json" ContentTypeJSONEachRow ContentType = "application/jsoneachrow" )
func (ContentType) String ¶ added in v0.2.0
func (c ContentType) String() string
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
func NewEndpoint ¶
type FastHttpHttpClientAdapter ¶
type FastHttpHttpClientAdapter struct {
// contains filtered or unexported fields
}
func WithFasthttp ¶ added in v0.5.0
func WithFasthttp() *FastHttpHttpClientAdapter
func WithFasthttpClient ¶ added in v0.5.0
func WithFasthttpClient(cli *fasthttp.Client) *FastHttpHttpClientAdapter
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
type NativeHttpClientAdapter ¶
type NativeHttpClientAdapter struct {
// contains filtered or unexported fields
}
func WithNetHttp ¶ added in v0.5.0
func WithNetHttp() *NativeHttpClientAdapter
func WithNetHttpClient ¶ added in v0.5.0
func WithNetHttpClient(cli *http.Client) *NativeHttpClientAdapter
type NewLineStream ¶ added in v0.4.0
type NewLineStream struct {
// contains filtered or unexported fields
}
type ProxyStream ¶ added in v0.4.0
type ProxyStream struct {
// contains filtered or unexported fields
}
type ReqOption ¶
func WithBaseURL ¶ added in v0.2.0
type ReqOptionFunc ¶
func (ReqOptionFunc) Configure ¶
func (f ReqOptionFunc) Configure(req Request) error
type Request ¶
type Request interface { Header Method() string SetMethod(string) SetURL(*url.URL) // SetBodyStream sets the stream of body data belonging to a request. bodySize parameter is needed // when using fasthttp implementation. SetBodyStream(rc io.ReadWriteCloser, bodySize int) SetBody([]byte) Body() []byte BodyStream() io.ReadWriteCloser URL() *url.URL }
type ResOption ¶
func WithMockedRes ¶ added in v0.2.0
type ResOptionFunc ¶
func (ResOptionFunc) Parse ¶
func (f ResOptionFunc) Parse(res Response) error
type Response ¶
type Response interface { Header Status() int StatusText() string Body() io.ReadCloser SetBody(rc io.ReadCloser) SetStatus(status int) }
type Stream ¶
func NewCSVStream ¶ added in v0.6.0
type StreamCallReqOption ¶ added in v0.3.0
type StreamCallReqOption[T any] interface { CallReqOption[T] // contains filtered or unexported methods }
type StreamCallReqOptionFunc ¶ added in v0.3.0
func WithRequestStreamBody ¶ added in v0.3.0
func WithRequestStreamBody[T, U any](r rangeable[U]) StreamCallReqOptionFunc[T]
type StreamFactory ¶
func NewCSVStreamFactory ¶ added in v0.6.0
func NewJSONEachRowStreamFactory ¶
func NewJSONEachRowStreamFactory[T any]() StreamFactory[T]
func NewNewLineStreamFactory ¶ added in v0.4.0
func NewNewLineStreamFactory() StreamFactory[[]byte]
func NewProxyStreamFactory ¶ added in v0.4.0
type StreamFactoryFunc ¶
type StreamFromReader ¶ added in v0.4.0
func NewStreamFromReader ¶ added in v0.4.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.