Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete makes a DELETE request against a server using the provided HTTP client. The url must be a fully-formed URL string. DEPRECATED. Use Request() instead.
func Get ¶
Get makes a GET request against a server using the provided HTTP client. The url must be a fully-formed URL string. DEPRECATED. Use Request() instead.
Types ¶
type Options ¶
type Options struct { CustomClient *http.Client ReqBody interface{} Results interface{} MoreHeaders map[string]string OkCodes []int StatusCode *int `DEPRECATED` DumpReqJson bool `UNSUPPORTED` ResponseJson *[]byte `DEPRECATED` Response **Response ContentType string `json:"Content-Type,omitempty"` ContentLength int64 `json:"Content-Length,omitempty"` Accept string `json:"Accept,omitempty"` SetHeaders func(r *http.Request) error }
Options describes a set of optional parameters to the various request calls.
The custom client can be used for a variety of purposes beyond selecting encrypted versus unencrypted channels. Transports can be defined to provide augmented logging, header manipulation, et. al.
If the ReqBody field is provided, it will be embedded as a JSON object. Otherwise, provide nil.
If JSON output is to be expected from the response, provide either a pointer to the container structure in Results, or a pointer to a nil-initialized pointer variable. The latter method will cause the unmarshaller to allocate the container type for you. If no response is expected, provide a nil Results value.
The MoreHeaders map, if non-nil or empty, provides a set of headers to add to those already present in the request. At present, only Accepted and Content-Type are set by default.
OkCodes provides a set of acceptable, positive responses.
If provided, StatusCode specifies a pointer to an integer, which will receive the returned HTTP status code, successful or not. DEPRECATED; use the Response.StatusCode field instead for new software.
ResponseJson, if specified, provides a means for returning the raw JSON. This is most useful for diagnostics. DEPRECATED; use the Response.JsonResult field instead for new software.
DumpReqJson, if set to true, will cause the request to appear to stdout for debugging purposes. This attribute may be removed at any time in the future; DO NOT use this attribute in production software.
Response, if set, provides a way to communicate the complete set of HTTP response, raw JSON, status code, and other useful attributes back to the caller. Note that the Request() method returns a Response structure as part of its public interface; you don't need to set the Response field here to use this structure. The Response field exists primarily for legacy or deprecated functions.
SetHeaders allows the caller to provide code to set any custom headers programmatically. Typically, this facility can invoke, e.g., SetBasicAuth() on the request to easily set up authentication. Any error generated will terminate the request and will propegate back to the caller.
type Response ¶
type Response struct { HttpResponse http.Response JsonResult []byte Results interface{} StatusCode int }
type UnexpectedResponseCodeError ¶
The UnexpectedResponseCodeError structure represents a mismatch in understanding between server and client in terms of response codes. Most often, this is due to an actual error condition (e.g., getting a 404 for a resource when you expect a 200). However, it needn't always be the case (e.g., getting a 204 (No Content) response back when a 200 is expected).
func (*UnexpectedResponseCodeError) Error ¶
func (err *UnexpectedResponseCodeError) Error() string