Documentation ¶
Index ¶
- Variables
- func NewRequest(t *testing.T, info *RequestInfo) *httptest.ResponseRecorder
- type RequestAuth
- type RequestInfo
- func (ri *RequestInfo) Body() (mime string, body io.Reader, err error)
- func (ri *RequestInfo) BodyJSON() (mime string, body io.Reader, err error)
- func (ri *RequestInfo) BodyMultipart() (mime string, body io.Reader, err error)
- func (ri *RequestInfo) ParseParams()
- func (ri *RequestInfo) PopulateQuery(qs url.Values)
- func (ri *RequestInfo) URL() string
Constants ¶
This section is empty.
Variables ¶
var DefaultRouter *mux.Router
DefaultRouter represents the router to be used if none are specified
Functions ¶
func NewRequest ¶
func NewRequest(t *testing.T, info *RequestInfo) *httptest.ResponseRecorder
NewRequest simulates a new http request executed against the api
Types ¶
type RequestAuth ¶
RequestAuth represents the auth data for a request
func NewRequestAuth ¶
func NewRequestAuth(s *auth.Session) *RequestAuth
NewRequestAuth creates a new request auth
func (*RequestAuth) ToBasicAuth ¶
func (ra *RequestAuth) ToBasicAuth() string
ToBasicAuth returns the data using the basic auth format
type RequestInfo ¶
type RequestInfo struct { Endpoint *router.Endpoint Params interface{} // Optional Auth *RequestAuth // Optional // Router is used to parse Mux Variables. Default on the api router Router *mux.Router // contains filtered or unexported fields }
RequestInfo represents the params accepted by NewRequest
func (*RequestInfo) Body ¶
func (ri *RequestInfo) Body() (mime string, body io.Reader, err error)
Body returns the full Body of the request
func (*RequestInfo) BodyJSON ¶
func (ri *RequestInfo) BodyJSON() (mime string, body io.Reader, err error)
BodyJSON returns the body of the request encoded in JSON FIXME(melvin): because the data are from a map of string, all the
JSON data will also be string. There's no way to use the output to recreate a new JSON object containing non string value
func (*RequestInfo) BodyMultipart ¶
func (ri *RequestInfo) BodyMultipart() (mime string, body io.Reader, err error)
BodyMultipart returns the body of the request as multipart data
func (*RequestInfo) ParseParams ¶
func (ri *RequestInfo) ParseParams()
ParseParams parses the params and copy them in the right list: urlParams, bodyParams, and queryParams
func (*RequestInfo) PopulateQuery ¶
func (ri *RequestInfo) PopulateQuery(qs url.Values)
PopulateQuery populate the query string of a request