v2.0.0-alpha.2 Latest Latest

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 8 Imported by: 0




This section is empty.


This section is empty.


func Get

func Get(url string, opts ...ReqOption) (*http.Response, []byte, error)

Get do a GET request

func MakeRequest

func MakeRequest(url string, opts ...ReqOption) (*http.Response, []byte, error)

MakeRequest create and do a request

func NewHandler

func NewHandler(handler http.HandlerFunc) *httptest.Server

NewHandler creates a new Server

func NewResponder

func NewResponder(response string) *httptest.Server

NewResponder creates a new Server with response

func ParseURI

func ParseURI(uri string) *url.URL

ParseURI is the version of url.ParseRequestURI that panics if incorrect, helpful to shorten the tests

func Post

func Post(url string, opts ...ReqOption) (*http.Response, []byte, error)

Post do a POST request


type ReqOption

type ReqOption func(o *ReqOpts) error

ReqOption request option type

func BasicAuth

func BasicAuth(username, password string) ReqOption

BasicAuth sets request basic auth

func Body

func Body(b string) ReqOption

Body sets request body

func Header(name, val string) ReqOption

Header sets request header

func Headers

func Headers(h http.Header) ReqOption

Headers sets request headers

func Host

func Host(h string) ReqOption

Host sets request host

func Method

func Method(m string) ReqOption

Method sets request method

type ReqOpts

type ReqOpts struct {
	Host    string
	Method  string
	Body    string
	Headers http.Header
	Auth    *utils.BasicAuth

ReqOpts request options

Jump to

Keyboard shortcuts

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