requests

package
v0.0.0-...-9d0e06d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBody

func ParseBody(body io.ReadCloser, dest any) error

func ParseResponse

func ParseResponse(response *http.Response, dest any) (err error)

ParseResponse ParseRequest read a body of response and try to Unmarshal into a struct passed by parameter

func ProcessResponse

func ProcessResponse(w http.ResponseWriter, resp interface{}, ctx context.Context, err error)

ProcessResponse Helper function to return a http response, performing some common checking

func ReadBody

func ReadBody(body io.ReadCloser) []byte

Types

type Request

type Request struct {
	BasicAuthentication struct {
		UserName, Password string
	}
	Timeout time.Duration
}

func NewRequest

func NewRequest() Request

func (*Request) Delete

func (r *Request) Delete(url string, headers map[string]string, params,
	dest interface{}) (resp *Response, err error)

func (*Request) Get

func (r *Request) Get(url string, headers map[string]string, dest interface{}) (resp *Response, err error)

Get realiza uma request GET e joga o resultado da request para a variavel dest

func (*Request) Post

func (r *Request) Post(url string, headers map[string]string, params,
	dest interface{}) (resp *Response, err error)

Post realiza uma request POST e joga o resultado da request para a variavel dest

func (*Request) Put

func (r *Request) Put(url string, headers map[string]string, params,
	dest interface{}) (resp *Response, err error)

Put realiza uma request PUT e joga o resultado da request para a variavel dest

func (*Request) Request

func (r *Request) Request(method, urlAddress string, headers map[string]string, params,
	dest interface{}) (resp *Response, err error)

Request realiza uma request e joga o resultado da request para o parametro `dest`

type Response

type Response struct {
	StatusCode   int
	HttpResponse *http.Response
	ResponseBody []byte
}

Jump to

Keyboard shortcuts

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