requests

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Get    string = "GET"
	Post   string = "POST"
	Put    string = "PUT"
	Patch  string = "PATCH"
	Delete string = "DELETE"
)

Supported http methods

Variables

This section is empty.

Functions

func AddParameters

func AddParameters(baseURL string, queryParams map[string]string) string

AddParameters adds query parameters to the URL.

func BuildHTTPRequest

func BuildHTTPRequest(request *Request) (*http.Request, error)

BuildHTTPRequest build a http request object

func EncodeURL

func EncodeURL(host string, format string, args ...interface{}) string

EncodeURL encode url

func SendPut

func SendPut(url, user, password string) error

SendPut send put http request

Types

type Request

type Request struct {
	User     string
	Password string
	Method   string
	URL      string
	Header   map[string]string
	Params   map[string]string
	Body     []byte
}

Request request info

func NewRequest

func NewRequest(url, method string, header map[string]string, params map[string]string, data []byte) *Request

NewRequest return Request

func (*Request) SetBasicAuth

func (req *Request) SetBasicAuth(user, password string)

SetBasicAuth set basic auth of request

type Response

type Response struct {
	StatusCode int
	Header     map[string][]string
	Body       []byte
}

Response response info

func Send

func Send(request *Request) (*Response, error)

Send send http request

func SendGet

func SendGet(url, user, password string) (*Response, error)

SendGet send get http request

Jump to

Keyboard shortcuts

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