request

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentTypeHeader value
	ContentTypeHeader = "Content-Type"
)
View Source
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 DoAndRead

func DoAndRead(ctx context.Context, request *http.Request) (io.ReadCloser, int, http.Header, error)

DoAndRead execute request and return output

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 Form

func Form(method string, url string, data url.Values, headers http.Header) (*http.Request, error)

Form prepare a Form request from given params

func GenerateBasicAuth

func GenerateBasicAuth(username string, password string) string

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 GetIP

func GetIP(r *http.Request) (ip string)

GetIP give remote IP

func JSON

func JSON(method string, url string, body interface{}, headers http.Header) (*http.Request, error)

JSON prepare a JSON request from given params

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

func ReadBodyRequest(r *http.Request) ([]byte, error)

ReadBodyRequest return content of a body request (defined as a ReadCloser)

func ReadBodyResponse

func ReadBodyResponse(r *http.Response) ([]byte, error)

ReadBodyResponse return content of a body response (defined as a ReadCloser)

func SetIP

func SetIP(r *http.Request, ip string)

SetIP set remote IP

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL