Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultTransport() http.RoundTripper
- type Client
- func (c *Client) Do(req *Request) (*Response, error)
- func (c *Client) Get(url string) (*Response, error)
- func (c *Client) GetFile(url, directory string) (int64, error)
- func (c *Client) Post(url string, contentType string, body io.Reader) (*Response, error)
- func (c *Client) PostForm(url string, data url.Values) (*Response, error)
- func (c *Client) PostJSON(url string, body interface{}) (*Response, error)
- func (c *Client) SetToken(token string)
- type Request
- type Response
Constants ¶
View Source
const ( HeaderAuthorization = "Authorization" AuthSchemeBearer = "Bearer" )
View Source
const ( HeaderContentType = "Content-Type" MIMEApplicationJSON = "application/json" MIMEApplicationXML = "application/xml" MIMETextXML = "text/xml" MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEMultipartForm = "multipart/form-data" )
View Source
const DefaultTimeout = 30 * time.Second
DefaultTimeout -
Variables ¶
View Source
var (
ErrUnsupportedMediaType = errors.New("unsupported media type")
)
Functions ¶
Types ¶
type Client ¶
A Client is an HTTP client.
func NewClient ¶
func NewClient(transport http.RoundTripper, jar http.CookieJar, timeout time.Duration) (*Client, error)
NewClient returns an HTTP client.
func NewClientWithProxy ¶
NewClientWithProxy -
func (*Client) PostForm ¶
PostForm sends a Post HTTP request with form data and returns an HTTP response.
type Request ¶
A Request represents an HTTP request to be sent by a client.
func NewRequest ¶
NewRequest returns a new Request given a method, URL, and optional body.
func (*Request) AddHeader ¶
AddHeader adds the key, value pair to the header. It appends to any existing values associated with key.
func (*Request) AddHeaders ¶
AddHeaders adds the multiple headers.
func (*Request) GetHeader ¶
GetHeader gets the first value associated with the given key. If there are no values associated with the key, Get returns "".
type Response ¶
Response represents the response from an HTTP request.
func (*Response) SaveAsFile ¶
SaveAsFile -
Click to show internal directories.
Click to hide internal directories.