request

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostWithHeadersWithNoRedirect

func PostWithHeadersWithNoRedirect(u string, headers http.Header, data models.FileData) (*http.Response, error)

PostWithHeadersWithNoRedirect uses the `post` method to make requests and prohibits redirection

Types

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request integrates some methods of network request

func NewRequest

func NewRequest(headers http.Header) *Request

NewRequest returns a new Request

func (*Request) Get

func (r *Request) Get(url string) (*Response, error)

Get uses the `get` method to get the response of the specified url

func (*Request) Post

func (r *Request) Post(url string, data models.FileData) (*Response, error)

Post uses the `post` method and the specified request body to make a request to the specified URL and get a response

func (*Request) PostMultipartForm

func (r *Request) PostMultipartForm(url, contentType string, reader io.Reader) (*Response, error)

PostMultipartForm uses the `post` method to make a request with a file as the request body

func (*Request) PostWithoutHeader

func (r *Request) PostWithoutHeader(u string, data models.FileData) (*Response, error)

PostWithoutHeader uses the `post` method and the specified request body to send a request without request headers to the specified URL and get a response

func (*Request) Put

func (r *Request) Put(url string, data models.FileData) (*Response, error)

Put uses the `put` method and the specified request body to make a request to the specified URL and get a response

type Response

type Response struct {
	// Response status code
	StatusCode int

	// Response body
	Body []byte

	// the request to get this Response
	Request *http.Request

	// Response header
	Header http.Header
}

Response is a network response that contains useful information

func (*Response) String

func (r *Response) String() string

String returns the string of the response body

Jump to

Keyboard shortcuts

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