Documentation ¶
Overview ¶
Package httpx contains http extensions.
Index ¶
- type Client
- func (c Client) Do(request *http.Request) ([]byte, error)
- func (c Client) DoJSON(request *http.Request, output interface{}) error
- func (c Client) FetchResource(ctx context.Context, URLPath string) ([]byte, error)
- func (c Client) FetchResourceAndVerify(ctx context.Context, URL, SHA256Sum string) ([]byte, error)
- func (c Client) GetJSON(ctx context.Context, resourcePath string, output interface{}) error
- func (c Client) GetJSONWithQuery(ctx context.Context, resourcePath string, query url.Values, output interface{}) error
- func (c Client) NewRequest(ctx context.Context, method, resourcePath string, query url.Values, ...) (*http.Request, error)
- func (c Client) NewRequestWithJSONBody(ctx context.Context, method, resourcePath string, query url.Values, ...) (*http.Request, error)
- func (c Client) PostJSON(ctx context.Context, resourcePath string, input, output interface{}) error
- func (c Client) PutJSON(ctx context.Context, resourcePath string, input, output interface{}) error
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Accept contains the accept header. Accept string // Authorization contains the authorization header. Authorization string // BaseURL is the base URL of the API. BaseURL string // HTTPClient is the real http client to use. HTTPClient *http.Client // Host allows to set a specific host header. This is useful // to implement, e.g., cloudfronting. Host string // Logger is the logger to use. Logger Logger // UserAgent is the user agent to use. UserAgent string }
Client is an extended client.
func (Client) DoJSON ¶
DoJSON performs the provided request and unmarshals the JSON response body into the provided output variable.
func (Client) FetchResource ¶
FetchResource fetches the specified resource and returns it.
func (Client) FetchResourceAndVerify ¶
FetchResourceAndVerify fetches and verifies a specific resource.
func (Client) GetJSON ¶
GetJSON reads the JSON resource at resourcePath and unmarshals the results into output. The request is bounded by the lifetime of the context passed as argument. Returns the error that occurred.
func (Client) GetJSONWithQuery ¶
func (c Client) GetJSONWithQuery( ctx context.Context, resourcePath string, query url.Values, output interface{}) error
GetJSONWithQuery is like GetJSON but also has a query.
func (Client) NewRequest ¶
func (c Client) NewRequest(ctx context.Context, method, resourcePath string, query url.Values, body io.Reader) (*http.Request, error)
NewRequest creates a new request.
func (Client) NewRequestWithJSONBody ¶
func (c Client) NewRequestWithJSONBody( ctx context.Context, method, resourcePath string, query url.Values, body interface{}) (*http.Request, error)
NewRequestWithJSONBody creates a new request with a JSON body
func (Client) PostJSON ¶
func (c Client) PostJSON( ctx context.Context, resourcePath string, input, output interface{}) error
PostJSON creates a JSON subresource of the resource at resourcePath using the JSON document at input and returning the result into the JSON document at output. The request is bounded by the context's lifetime. Returns the error that occurred.