Documentation ¶
Index ¶
- func IsJson(data []byte) bool
- func IsXML(data []byte) bool
- type DownloadResult
- type Request
- type RequestResponse
- func Delete(url string) (*RequestResponse, error)
- func Get(url string) (*RequestResponse, error)
- func Make(method, url string, data []byte, dataType, responseType string, ...) (*RequestResponse, error)
- func Patch(url string, data []byte) (*RequestResponse, error)
- func Post(url string, data []byte) (*RequestResponse, error)
- func Put(url string, data []byte) (*RequestResponse, error)
- func (r *RequestResponse) Body() io.ReadCloser
- func (r *RequestResponse) CloseBody() error
- func (r *RequestResponse) DownloadAsFile(fileName string) (*DownloadResult, error)
- func (r *RequestResponse) Headers() http.Header
- func (r *RequestResponse) ReadBody() ([]byte, error)
- func (r *RequestResponse) Status() string
- func (r *RequestResponse) StatusCode() int
- func (r *RequestResponse) ToJson(saveTo interface{}) error
- func (r *RequestResponse) ToString(saveTo interface{}) error
- func (r *RequestResponse) ToXML(saveTo interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DownloadResult ¶
type Request ¶
type RequestResponse ¶
func Delete ¶
func Delete(url string) (*RequestResponse, error)
func Get ¶
func Get(url string) (*RequestResponse, error)
func Make ¶
func Make(method, url string, data []byte, dataType, responseType string, saveTo interface{}, headers map[string]string) (*RequestResponse, error)
Either call this function to create a request Or call Request type directly and call Make(). Both will do the same.
func (*RequestResponse) DownloadAsFile ¶
func (r *RequestResponse) DownloadAsFile(fileName string) (*DownloadResult, error)
Downloads the body and saves it into the given path
func (*RequestResponse) Headers ¶
func (r *RequestResponse) Headers() http.Header
Returns response headers
func (*RequestResponse) ReadBody ¶
func (r *RequestResponse) ReadBody() ([]byte, error)
Reads response body into bytes and returns the result
func (*RequestResponse) Status ¶
func (r *RequestResponse) Status() string
Returns status (string: 200 OK)
func (*RequestResponse) StatusCode ¶
func (r *RequestResponse) StatusCode() int
Returns response status code (int: 200)
func (*RequestResponse) ToJson ¶
func (r *RequestResponse) ToJson(saveTo interface{}) error
Unmarshals json response and saves it into the given pointer
func (*RequestResponse) ToString ¶
func (r *RequestResponse) ToString(saveTo interface{}) error
converts response to string and saves into the given pointer
func (*RequestResponse) ToXML ¶
func (r *RequestResponse) ToXML(saveTo interface{}) error
Unmarshals xml response and saves into the given pointer
Click to show internal directories.
Click to hide internal directories.