httphelper

package
v0.0.0-...-d2182b9 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidStatusCode = errors.New("invalid status code")
)

Functions

func GetBodyReader

func GetBodyReader(body interface{}) (io.Reader, error)

Types

type Client

type Client interface {
	Get(request Request) *ResponseFail
	Post(request Request) *ResponseFail
	Patch(request Request) *ResponseFail
	Put(request Request) *ResponseFail
	Delete(request Request) *ResponseFail
	SetAuthBasicToHeader(user, password string)
}

func New

func New(opts Options) Client

type Options

type Options struct {
	BaseURL    string
	HttpClient *http.Client
	Timeout    time.Duration
	Header     map[string]string
}

type Request

type Request struct {
	Context     context.Context
	Endpoint    string
	Header      map[string]string
	Body        interface{}
	Destination interface{}
}

type ResponseFail

type ResponseFail struct {
	Err        error
	StatusCode int
	Body       []byte
	Data       map[string]interface{}
	Header     http.Header
}

func DecodeResponse

func DecodeResponse(response *http.Response, dest interface{}) *ResponseFail

Jump to

Keyboard shortcuts

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