Documentation ¶
Index ¶
- Variables
- func AddQueryParams(baseURL string, queryParams map[string]string) string
- func BuildRequestObject(request Request) (*http.Request, error)
- func EncodeBody(body interface{}) (*bytes.Buffer, error)
- func MakeRequest(req *http.Request) (*http.Response, error)
- func Validate(allowed map[string]bool, params interface{}) (map[string]string, error)
- type Client
- type Method
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = &Client{HTTPClient: http.DefaultClient}
DefaultClient is used if no custom HTTP client is defined http.Client configures a timeout that short-circuits long-running connections. The default for this value is 0, which is interpreted as “no timeout”, meaning if no custom client with a TimeOut value specified is defined, in case of API outage the GO program will continue to hang A custom TimeoutClient is defined below.
var NetClient = &http.Client{ Timeout: time.Second * 8, }
Custom client with time out after 8 seconds
var TimeoutClient = &Client{HTTPClient: NetClient}
Functions ¶
func AddQueryParams ¶
AddQueryParams takes a map of query params and appends each to the URL
func BuildRequestObject ¶
BuildRequestObject creates the HTTP request object.
func EncodeBody ¶
EncodeBody takes an interface and returns a *bytes.Buffer suitable for making RESTful requests with
func MakeRequest ¶
MakeRequest makes the API call.
Types ¶
type Client ¶
Client allows modification of client headers, redirect policy and other settings See https://golang.org/pkg/net/http
func (*Client) MakeRequest ¶
MakeRequest makes the API call.
type Request ¶
type Request struct { Method Method URL string Headers map[string]string QueryParams map[string]string Body *bytes.Buffer }
Request holds the request to an API Call.
type Response ¶
Response holds the response from an API call.
func BuildResponse ¶
BuildResponse builds the response struct.