Documentation ¶
Overview ¶
Gopencils is a Golang REST Client with which you can easily consume REST API's. Supported Response formats: JSON
Index ¶
- type ApiStruct
- type BasicAuth
- type Resource
- func (r *Resource) Delete() (*Resource, error)
- func (r *Resource) Get() (*Resource, error)
- func (r *Resource) Head() (*Resource, error)
- func (r *Resource) NewChildIdResource(id string) *Resource
- func (r *Resource) NewChildResource(resourceName string, response interface{}) *Resource
- func (r *Resource) Options() (*Resource, error)
- func (r *Resource) Patch(payload interface{}) (*Resource, error)
- func (r *Resource) Post(payload interface{}) (*Resource, error)
- func (r *Resource) Put(payload interface{}) (*Resource, error)
- func (r *Resource) SetClient(c *http.Client)
- func (r *Resource) SetHeader(key string, value string)
- func (r *Resource) SetPayload(args interface{}) io.Reader
- func (r *Resource) SetQuery(querystring map[string]string) *Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiStruct ¶
type ApiStruct struct { BaseUrl *url.URL BasicAuth *BasicAuth Client *http.Client Cookies *cookiejar.Jar PathSuffix string }
Main Api Instance. No Options yet supported.
type Resource ¶
type Resource struct { Api *ApiStruct Url string QueryValues url.Values Payload io.Reader Headers http.Header Response interface{} Raw *http.Response // contains filtered or unexported fields }
Resource is basically an url relative to given API Baseurl.
func Api ¶
Create a new API Instance and returns a Resource Accepts URL as parameter, and either a Basic Auth or a OAuth2 Client.
func (*Resource) Delete ¶
Performs a Delete request on given Resource. Call SetQuery beforehand if you want to set the query string of the DELETE request.
func (*Resource) Get ¶
Performs a GET request on given Resource Call SetQuery beforehand if you want to set the query string of the GET request.
func (*Resource) Head ¶
Performs a HEAD request on given Resource Call SetQuery beforehand if you want to set the query string of the HEAD request.
func (*Resource) NewChildIdResource ¶
Same as Res() Method, but returns a Resource with url resource/:id
func (*Resource) NewChildResource ¶
Creates a new Resource.
func (*Resource) Options ¶
Performs a OPTIONS request on given Resource. Call SetQuery beforehand if you want to set the query string of the OPTIONS request.
func (*Resource) Patch ¶
Performs a PATCH request on given Resource. Accepts interface{} as parameter, will be used as payload.
func (*Resource) Post ¶
Performs a POST request on given Resource. Accepts interface{} as parameter, will be used as payload.
func (*Resource) Put ¶
Performs a PUT request on given Resource. Accepts interface{} as parameter, will be used as payload.
func (*Resource) SetClient ¶
Overwrites the client that will be used for requests. For example if you want to use your own client with OAuth2
func (*Resource) SetPayload ¶
Sets Payload for current Resource