Documentation ¶
Index ¶
- Constants
- func Do(ctx context.Context, method string, url string, body io.Reader, ...) (io.ReadCloser, int, http.Header, error)
- func DoAndRead(ctx context.Context, request *http.Request) (io.ReadCloser, int, http.Header, error)
- func DoAndReadWithClient(ctx context.Context, client http.Client, request *http.Request) (io.ReadCloser, int, http.Header, error)
- func DoJSON(ctx context.Context, url string, data interface{}, headers http.Header, ...) (io.ReadCloser, int, http.Header, error)
- func Form(method string, url string, data url.Values, headers http.Header) (*http.Request, error)
- func GenerateBasicAuth(username string, password string) string
- func Get(ctx context.Context, url string, headers http.Header) (io.ReadCloser, int, http.Header, error)
- func GetIP(r *http.Request) (ip string)
- func JSON(method string, url string, body interface{}, headers http.Header) (*http.Request, error)
- func New(method string, url string, body io.Reader, headers http.Header) (req *http.Request, err error)
- func PostForm(ctx context.Context, url string, data url.Values, headers http.Header) (io.ReadCloser, int, http.Header, error)
- func ReadBody(body io.ReadCloser) (content []byte, err error)
- func ReadBodyRequest(r *http.Request) ([]byte, error)
- func ReadBodyResponse(r *http.Response) ([]byte, error)
- func SetIP(r *http.Request, ip string)
Constants ¶
const (
// ContentTypeHeader value
ContentTypeHeader = "Content-Type"
)
const (
// ForwardedForHeader that proxy uses to fill
ForwardedForHeader = "X-Forwarded-For"
)
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do(ctx context.Context, method string, url string, body io.Reader, headers http.Header) (io.ReadCloser, int, http.Header, error)
Do send given method with given content to URL with optional headers supplied
func DoAndReadWithClient ¶
func DoAndReadWithClient(ctx context.Context, client http.Client, request *http.Request) (io.ReadCloser, int, http.Header, error)
DoAndReadWithClient execute request and return output with given client
func DoJSON ¶
func DoJSON(ctx context.Context, url string, data interface{}, headers http.Header, method string) (io.ReadCloser, int, http.Header, error)
DoJSON send given method with given interface{} as JSON to URL with optional headers supplied
func GenerateBasicAuth ¶
GenerateBasicAuth generates Basic Auth for given username and password
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 New ¶
func New(method string, url string, body io.Reader, headers http.Header) (req *http.Request, err error)
New prepare a request from given params
func PostForm ¶
func PostForm(ctx context.Context, url string, data url.Values, headers http.Header) (io.ReadCloser, int, http.Header, error)
PostForm send form via POST with urlencoded data
func ReadBody ¶
func ReadBody(body io.ReadCloser) (content []byte, err error)
ReadBody return content of given body
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)
Types ¶
This section is empty.