Documentation ¶
Index ¶
- Constants
- Variables
- type Request
- type RequestOption
- func Accept(ct string) RequestOption
- func AddHeaders(h ...map[string]string) RequestOption
- func ContentType(ct string) RequestOption
- func ExpectStatus(codes ...int) RequestOption
- func JSON() RequestOption
- func QueryParams(m map[string]string) RequestOption
- func RequestXML() RequestOption
- func SetClient(client *http.Client) RequestOption
- func SetCookieJar(jar *cookiejar.Jar) RequestOption
- func WithBody(reader io.Reader) RequestOption
- type Response
- func Delete(url string, opts ...RequestOption) (*Response, error)
- func Get(url string, opts ...RequestOption) (*Response, error)
- func Head(url string, opts ...RequestOption) (*Response, error)
- func Post(url string, opts ...RequestOption) (*Response, error)
- func Put(url string, opts ...RequestOption) (*Response, error)
Constants ¶
View Source
const ( // ContentTypeJSON is the mimetype for json ContentTypeJSON = "application/json" // ContentTypeXML is the mimetype for xml ContentTypeXML = "application/xml" // DefaultAccept is the default Accept mimetype for requests DefaultAccept = "*/*" )
Variables ¶
View Source
var ( // ErrInvalidStatusCode is the error type returned when the user sets expected // status code with `ExpectStatus`, but it does not match ErrInvalidStatusCode = errors.New("response had an invalid status code") )
Functions ¶
This section is empty.
Types ¶
type RequestOption ¶
RequestOption is a type for functional options
func Accept ¶
func Accept(ct string) RequestOption
Accept allows setting the Accept header individually
func AddHeaders ¶
func AddHeaders(h ...map[string]string) RequestOption
AddHeaders adds custom headers to the request
func ContentType ¶
func ContentType(ct string) RequestOption
ContentType allows setting the content-type for the request
func ExpectStatus ¶
func ExpectStatus(codes ...int) RequestOption
ExpectStatus sets expected status codes from a response
func QueryParams ¶
func QueryParams(m map[string]string) RequestOption
QueryParams sets the query params for a request
func RequestXML ¶
func RequestXML() RequestOption
RequestXML sets a request to accept and respond with json
func SetClient ¶
func SetClient(client *http.Client) RequestOption
SetClient sets a custom http.Client to use for the request
func SetCookieJar ¶
func SetCookieJar(jar *cookiejar.Jar) RequestOption
SetCookieJar sets the cookie jar to be used with requests
func WithBody ¶
func WithBody(reader io.Reader) RequestOption
WithBody provides the body to be used with the http request
type Response ¶
Response represents an http response
func Delete ¶
func Delete(url string, opts ...RequestOption) (*Response, error)
Delete performs an http DELETE
func Head ¶
func Head(url string, opts ...RequestOption) (*Response, error)
Head performs an http HEAD
Click to show internal directories.
Click to hide internal directories.