Documentation ¶
Index ¶
- Constants
- func AddQueryParams(baseURL string, opts ...interface{}) (string, error)
- func OAuth(clientID, clientSecret string, endpoint oauth2.Endpoint) (*oauth2.Token, error)
- func OAuthClientCredentials(clientID, clientSecret, tokenURL string) (*oauth2.Token, error)
- type Client
- func (c *Client) ConstructRequest(r, body interface{}) *resty.Request
- func (c *Client) Delete(url string, r, body interface{}) (*Response, error)
- func (c *Client) Dispatch(request *resty.Request) (*Response, error)
- func (c *Client) Get(url string, r, body interface{}) (*Response, error)
- func (c *Client) Patch(url string, r, body interface{}) (*Response, error)
- func (c *Client) Post(url string, r, body interface{}) (*Response, error)
- func (c *Client) Put(url string, r, body interface{}) (*Response, error)
- func (c *Client) RequestURL(template string, args ...interface{}) string
- func (c *Client) RequestURLWithQueryParams(url string, opts ...interface{}) (string, error)
- func (c *Client) SetBaseURL(url string)
- type Response
Constants ¶
const ( GetMethod = "GET" PostMethod = "POST" PutMethod = "PUT" DeleteMethod = "DELETE" PatchMethod = "PATCH" )
Variables ¶
This section is empty.
Functions ¶
func AddQueryParams ¶
AddQueryParams takes a slice of opts and adds each field as escaped URL query parameters to a base URL string.
Each element in opts must be a struct whose fields contain "url" tags.
Based on: https://github.com/google/go-github/blob/master/github/github.go#L226
Types ¶
type Client ¶
type Client struct { *resty.Client // contains filtered or unexported fields }
Client represents a SimpleResty client. It embeds the resty.client so users have access to its methods.
func New ¶
func New() *Client
New function creates a new simpleresty client with base url set to empty string.
Users can set the base string later in their code.
func NewWithBaseURL ¶ added in v0.2.3
NewWithBaseURL creates a new simpleresty client with base url set.
func (*Client) ConstructRequest ¶
func (c *Client) ConstructRequest(r, body interface{}) *resty.Request
ConstructRequest creates a new request.
func (*Client) Dispatch ¶
Dispatch method is a wrapper around the send method which performs the HTTP request using the method and URL already defined.
func (*Client) RequestURL ¶
RequestURL appends the template argument to the base URL and returns the full request URL.
func (*Client) RequestURLWithQueryParams ¶
RequestURLWithQueryParams first constructs the request URL and then appends any URL encoded query parameters.
This function operates nearly the same as RequestURL
func (*Client) SetBaseURL ¶
SetBaseURL sets the base url for the client.
type Response ¶
type Response struct { // Request representss the response's original request. Request *resty.Request // RequestURL is the request URL. RequestURL string // RequestMethod is the request method such as GET. RequestMethod string // Request body is the request body in JSON string format. RequestBody string // Resp represents the entire HTTP response. Resp *resty.Response // Status is the response status in string format such as '200 OK'. Status string // StatusCode is response status in integer format such as 200. StatusCode int // Body is the response body in JSON String format. Body string }
Response represents the response after executing a HTTP request.