|
@@ -29,12 +29,12 @@ type serverResponse struct {
|
|
|
|
|
|
// head sends an http request to the docker API using the method HEAD.
|
|
|
func (cli *Client) head(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
|
|
|
- return cli.sendRequest(ctx, "HEAD", path, query, nil, headers)
|
|
|
+ return cli.sendRequest(ctx, http.MethodHead, path, query, nil, headers)
|
|
|
}
|
|
|
|
|
|
// get sends an http request to the docker API using the method GET with a specific Go context.
|
|
|
func (cli *Client) get(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
|
|
|
- return cli.sendRequest(ctx, "GET", path, query, nil, headers)
|
|
|
+ return cli.sendRequest(ctx, http.MethodGet, path, query, nil, headers)
|
|
|
}
|
|
|
|
|
|
// post sends an http request to the docker API using the method POST with a specific Go context.
|
|
@@ -43,21 +43,21 @@ func (cli *Client) post(ctx context.Context, path string, query url.Values, obj
|
|
|
if err != nil {
|
|
|
return serverResponse{}, err
|
|
|
}
|
|
|
- return cli.sendRequest(ctx, "POST", path, query, body, headers)
|
|
|
+ return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers)
|
|
|
}
|
|
|
|
|
|
func (cli *Client) postRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
|
|
|
- return cli.sendRequest(ctx, "POST", path, query, body, headers)
|
|
|
+ return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers)
|
|
|
}
|
|
|
|
|
|
// putRaw sends an http request to the docker API using the method PUT.
|
|
|
func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
|
|
|
- return cli.sendRequest(ctx, "PUT", path, query, body, headers)
|
|
|
+ return cli.sendRequest(ctx, http.MethodPut, path, query, body, headers)
|
|
|
}
|
|
|
|
|
|
// delete sends an http request to the docker API using the method DELETE.
|
|
|
func (cli *Client) delete(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
|
|
|
- return cli.sendRequest(ctx, "DELETE", path, query, nil, headers)
|
|
|
+ return cli.sendRequest(ctx, http.MethodDelete, path, query, nil, headers)
|
|
|
}
|
|
|
|
|
|
type headers map[string][]string
|
|
@@ -79,7 +79,7 @@ func encodeBody(obj interface{}, headers headers) (io.Reader, headers, error) {
|
|
|
}
|
|
|
|
|
|
func (cli *Client) buildRequest(method, path string, body io.Reader, headers headers) (*http.Request, error) {
|
|
|
- expectedPayload := (method == "POST" || method == "PUT")
|
|
|
+ expectedPayload := (method == http.MethodPost || method == http.MethodPut)
|
|
|
if expectedPayload && body == nil {
|
|
|
body = bytes.NewReader([]byte{})
|
|
|
}
|