dub

package
v0.0.0-...-fa313d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddQuery

func AddQuery(reqUrl string, query map[string][]string) string

Types

type AuthSpec

type AuthSpec interface {
	Token() string
}

func NewBasicAuth

func NewBasicAuth(user, pass string) AuthSpec

func NewTokenAuth

func NewTokenAuth(token string) AuthSpec

type BasicAuth

type BasicAuth struct {
	User, Pass string
}

func (*BasicAuth) Token

func (b *BasicAuth) Token() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Make

func Make(t http.RoundTripper) *Client

Returns a dub.Client instance allowing the user to specify their own http.Transport

func New

func New() *Client

Returns a dub.Client instance with a preconfigured http.Transport

func Wrap

func Wrap(c *http.Client) *Client

Wraps an existing http.Client with a dub.Client

func (*Client) Connect

func (c *Client) Connect(url string) *Request

func (*Client) Delete

func (c *Client) Delete(url string) *Request

func (*Client) Get

func (c *Client) Get(url string) *Request

func (*Client) Head

func (c *Client) Head(url string) *Request

func (*Client) Options

func (c *Client) Options(url string) *Request

func (*Client) Patch

func (c *Client) Patch(url string) *Request

func (*Client) Post

func (c *Client) Post(url string) *Request

func (*Client) Put

func (c *Client) Put(url string) *Request

func (*Client) Trace

func (c *Client) Trace(url string) *Request

type FieldPart

type FieldPart struct {
	// contains filtered or unexported fields
}

func NewFieldPart

func NewFieldPart(param, value string) *FieldPart

func (*FieldPart) Build

func (f *FieldPart) Build(w *multipart.Writer) error

type FilePart

type FilePart struct {
	// contains filtered or unexported fields
}

func NewFilePart

func NewFilePart(param, path string) *FilePart

func (*FilePart) Build

func (f *FilePart) Build(w *multipart.Writer) (err error)

type Multipart

type Multipart struct {
	Parts []Part
	MultipartPayload
	// contains filtered or unexported fields
}

func NewAllocMultipart

func NewAllocMultipart() *Multipart

func NewPipedMultipart

func NewPipedMultipart() *Multipart

func (*Multipart) AddField

func (m *Multipart) AddField(param, value string) *Multipart

func (*Multipart) AddFile

func (m *Multipart) AddFile(param, path string) *Multipart

func (*Multipart) AddFileStream

func (m *Multipart) AddFileStream(param, filename string, data io.Reader) *Multipart

func (*Multipart) Assemble

func (m *Multipart) Assemble() error

func (*Multipart) Close

func (m *Multipart) Close() error

func (*Multipart) ContentType

func (m *Multipart) ContentType() string

func (*Multipart) Len

func (m *Multipart) Len() int

func (*Multipart) Read

func (m *Multipart) Read(p []byte) (int, error)

type MultipartPayload

type MultipartPayload interface {
	io.ReadCloser
	Len() int
	Ready() bool
	DoAssemble(*multipart.Writer, []Part) error
}

Represents the constructed multipart form data payload as an io.ReadCloser. Implementations will be used to build a Multipart instance for a request body.

func NewAllocPayload

func NewAllocPayload(buffer io.Reader) MultipartPayload

func NewPipedPayload

func NewPipedPayload(pr *io.PipeReader, pw *io.PipeWriter) MultipartPayload

func NewWireTapPayload

func NewWireTapPayload(wrapped MultipartPayload, onRead func([]byte) error) MultipartPayload

type Opts

type Opts struct {
	Cookies      []*http.Cookie
	Headers      map[string][]string
	Auth         AuthSpec
	ContentType  string
	OnProgress   []ProgressHandler
	OnBeforeSend []RawRequestHandler
}

type Part

type Part interface {
	Build(*multipart.Writer) error
}

type Progress

type Progress struct {
	Current     int64
	Total       int64
	RawRequest  *http.Request
	RawResponse *http.Response
	// contains filtered or unexported fields
}

type ProgressHandler

type ProgressHandler func(pr *Progress) error

type RawRequestHandler

type RawRequestHandler func(*http.Request) error

type Request

type Request struct {
	Url, Method string

	Cookies []*http.Cookie
	Headers http.Header
	Body    io.Reader
	// contains filtered or unexported fields
}

func (*Request) AddQuery

func (r *Request) AddQuery(query map[string][]string) *Request

func (*Request) Auth

func (r *Request) Auth(auth AuthSpec) *Request

func (*Request) BeforeSend

func (r *Request) BeforeSend(handler RawRequestHandler) *Request

func (*Request) ContentType

func (r *Request) ContentType(contentType string) *Request

func (*Request) Cookie

func (r *Request) Cookie(cookie *http.Cookie) *Request

func (*Request) Data

func (r *Request) Data(data io.Reader) *Request

func (*Request) DataString

func (r *Request) DataString(data string) *Request

func (*Request) Do

func (r *Request) Do(onResponse ResponseHandler) error

func (*Request) Header

func (r *Request) Header(key, value string) *Request

func (*Request) OnProgress

func (r *Request) OnProgress(handler ProgressHandler) *Request

func (*Request) Opts

func (r *Request) Opts(opts *Opts) *Request

func (*Request) SetCookies

func (r *Request) SetCookies(cookies []*http.Cookie) *Request

func (*Request) SetHeaders

func (r *Request) SetHeaders(headers map[string][]string) *Request

type Response

type Response struct {
	Status  int
	Headers http.Header
	Raw     *http.Response
	// contains filtered or unexported fields
}

func (*Response) Consume

func (r *Response) Consume(doRead ResponseBodyConsumer) error

func (*Response) IsAuthError

func (r *Response) IsAuthError() bool

func (*Response) IsError

func (r *Response) IsError() bool

func (*Response) IsNotFound

func (r *Response) IsNotFound() bool

func (*Response) IsRedirect

func (r *Response) IsRedirect() bool

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

func (*Response) IsSuccessOrRedirect

func (r *Response) IsSuccessOrRedirect() bool

func (*Response) OnProgress

func (r *Response) OnProgress(handler ProgressHandler) *Response

func (*Response) ReadAll

func (r *Response) ReadAll() ([]byte, error)

type ResponseBodyConsumer

type ResponseBodyConsumer func(io.Reader) error

type ResponseHandler

type ResponseHandler func(*Response) error

type StreamPart

type StreamPart struct {
	// contains filtered or unexported fields
}

func NewStreamPart

func NewStreamPart(param, filename string, data io.Reader) *StreamPart

func (*StreamPart) Build

func (s *StreamPart) Build(w *multipart.Writer) (err error)

type TokenAuth

type TokenAuth struct {
	BearerToken string
}

func (*TokenAuth) Token

func (t *TokenAuth) Token() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL