Documentation ¶
Overview ¶
Package api exposes a low-level interface to the MyRadio API.
It exposes the Requester interface for types that represent connections to the API, methods for constructing Requesters, and functions and methods for using Requesters to make requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPMethod ¶
type HTTPMethod int
HTTPMethod guards against incorrect methods being specified through strings
const ( // GetReq corresponds to GET GetReq HTTPMethod = iota // PostReq corresponds to POST PostReq // PutReq corresponds to PUT PutReq // PatchReq corresponds to PATCH PatchReq // DeleteReq corresponds to DELETE DeleteReq )
func (HTTPMethod) String ¶
func (m HTTPMethod) String() (string, error)
String converts a HTTPMethod object into a usable request method string
type Request ¶
type Request struct { // The endpoint, as a suffix of the API root URL. Endpoint string // The set of mixins to use. Mixins []string // The map of parameters to use. Params map[string][]string // The type of request (i.e. GET/POST etc.) ReqType HTTPMethod // The body of the request Body bytes.Buffer }
Request represents an API request being built.
func NewRequest ¶
NewRequest constructs a new request for the given endpoint.
func NewRequestf ¶
NewRequestf constructs a new request for the endpoint constructed by the given format string and parameters.
type Requester ¶
type Requester interface { // Do fulfils an API request. Do(r *Request) *Response DoToken(r *Request, token string) *Response }
Requester is the type of anything that can handle an API request.
func NewRequester ¶
NewRequester creates a new 'live' requester.