Documentation ¶
Index ¶
- Constants
- Variables
- func MustBytes(b []byte, _ error) []byte
- func MustString(s string, _ error) string
- func NewReader(input interface{}) *strings.Reader
- func NewStructIO(input interface{}) *strings.Readerdeprecated
- type Fetch
- func (f *Fetch) Delete(url string, reader io.Reader) (*Response, error)
- func (f *Fetch) DeleteWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
- func (f *Fetch) Do(req *http.Request) (*Response, error)
- func (f *Fetch) DoWithContext(ctx context.Context, req *http.Request) (*Response, error)
- func (f *Fetch) Get(url string, reader io.Reader) (*Response, error)
- func (f *Fetch) GetWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
- func (f *Fetch) IsJSON() *Fetch
- func (f *Fetch) Options(url string, reader io.Reader) (*Response, error)
- func (f *Fetch) OptionsWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
- func (f *Fetch) Patch(url string, reader io.Reader) (*Response, error)
- func (f *Fetch) PatchWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
- func (f *Fetch) Post(url string, reader io.Reader) (*Response, error)
- func (f *Fetch) PostWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
- func (f *Fetch) Put(url string, reader io.Reader) (*Response, error)
- func (f *Fetch) PutWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
- type Options
- type Response
Constants ¶
const DefaultTimeout = time.Duration(30 * time.Second)
DefaultTimeout defined timeout default for any request
Variables ¶
var ErrEmptyBody = fmt.Errorf("the body of response is empty")
ErrEmptyBody returns when there is no body to read
Functions ¶
func MustString ¶
MustString ignore any error and return a string
func NewReader ¶
NewReader this function will return a new reader if the format is JSON Valid format it will be convert before send, if is not json will send as come. Use a POINT for input variable
func NewStructIO
deprecated
Types ¶
type Fetch ¶
Fetch use http default but defined with a timeout.
func NewDefault ¶
func NewDefault() *Fetch
NewDefault get fetcher with netTransport and timeout defined
func (*Fetch) DeleteWithContext ¶
func (f *Fetch) DeleteWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
DeleteWithContext execute DoWithContext but define request to method DELETE
func (*Fetch) DoWithContext ¶
DoWithContext execute any kind of request passing context
func (*Fetch) GetWithContext ¶
func (f *Fetch) GetWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
GetWithContext execute DoWithContext but define request to method GET
func (*Fetch) OptionsWithContext ¶
func (f *Fetch) OptionsWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
OptionsWithContext execute DoWithContext but define request to method OPTIONS
func (*Fetch) PatchWithContext ¶
func (f *Fetch) PatchWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
PatchWithContext execute DoWithContext but define request to method PATCH
func (*Fetch) PostWithContext ¶
func (f *Fetch) PostWithContext(ctx context.Context, url string, reader io.Reader) (*Response, error)
PostWithContext execute DoWithContext but define request to method POST
type Options ¶
type Options struct { Header http.Header Timeout time.Duration Host string Transport *http.Transport }
Options default for any request in client
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns options with timeout defined
type Response ¶
Response helper work with response from http.Client
func (*Response) BodyIsEmpty ¶
BodyIsEmpty return if body is empty or not.