Documentation
¶
Index ¶
- Constants
- func Do(ctx context.Context, req *http.Request) (io.ReadCloser, int, http.Header, error)
- func DoWithClient(ctx context.Context, client http.Client, req *http.Request) (body io.ReadCloser, status int, headers http.Header, err error)
- func Form(ctx context.Context, method string, url string, data url.Values, ...) (*http.Request, error)
- func Get(ctx context.Context, url string, headers http.Header) (io.ReadCloser, int, http.Header, error)
- func JSON(ctx context.Context, method string, url string, body interface{}, ...) (*http.Request, error)
- func New(ctx context.Context, method string, url string, body io.Reader, ...) (*http.Request, error)
- func Post(ctx context.Context, url string, data url.Values, headers http.Header) (io.ReadCloser, int, http.Header, error)
- func PostJSON(ctx context.Context, url string, data interface{}, headers http.Header) (io.ReadCloser, int, http.Header, error)
- func ReadBodyRequest(r *http.Request) ([]byte, error)
- func ReadBodyResponse(r *http.Response) ([]byte, error)
- func ReadContent(body io.ReadCloser) (content []byte, err error)
Constants ¶
View Source
const (
// ContentTypeHeader value
ContentTypeHeader = "Content-Type"
)
Variables ¶
This section is empty.
Functions ¶
func DoWithClient ¶
func DoWithClient(ctx context.Context, client http.Client, req *http.Request) (body io.ReadCloser, status int, headers http.Header, err error)
DoWithClient execute request and return output with given client
func Form ¶
func Form(ctx context.Context, method string, url string, data url.Values, headers http.Header) (*http.Request, error)
Form prepare a Form request from given params
func Get ¶
func Get(ctx context.Context, url string, headers http.Header) (io.ReadCloser, int, http.Header, error)
Get send GET request to URL with optional headers supplied
func JSON ¶
func JSON(ctx context.Context, method string, url string, body interface{}, headers http.Header) (*http.Request, error)
JSON prepare a JSON request from given params
func New ¶
func New(ctx context.Context, method string, url string, body io.Reader, headers http.Header) (*http.Request, error)
New prepare a request from given params
func Post ¶
func Post(ctx context.Context, url string, data url.Values, headers http.Header) (io.ReadCloser, int, http.Header, error)
Post send form via POST with urlencoded data
func PostJSON ¶
func PostJSON(ctx context.Context, url string, data interface{}, headers http.Header) (io.ReadCloser, int, http.Header, error)
PostJSON send given method with given interface{} as JSON to URL with optional headers supplied
func ReadBodyRequest ¶
ReadBodyRequest return content of a body request (defined as a ReadCloser)
func ReadBodyResponse ¶
ReadBodyResponse return content of a body response (defined as a ReadCloser)
func ReadContent ¶
func ReadContent(body io.ReadCloser) (content []byte, err error)
ReadContent return content of given body
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.