rest

package module
v0.0.0-...-3fa8721 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 14 Imported by: 1

README

rest - Golang wrapper for making HTTP requests

Development status

Incomplete

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(log xop.Log) *rest.RequestOpts

Types

type RequestOpts

type RequestOpts struct {
	// Log          xm.Logger
	URL          string
	BaseURL      string
	HasData      bool
	Data         interface{}
	HasRaw       bool
	Raw          []byte
	PathParams   map[string]string
	QueryParams  url.Values
	Encoder      func(interface{}) ([]byte, error)
	Decoder      func([]byte, interface{}) error
	DecodeReader func(io.Reader, interface{}) error
	Method       string
	HasReader    bool
	Reader       io.Reader
	Client       *http.Client
	Cookies      []*http.Cookie
	Context      context.Context
	DecodeStatus map[int]interface{}
	Before       func(*RequestOpts, *http.Request) error
	After        func(Result) Result
	AlwaysRead   bool
	Description  string
}

func Make

func Make() *RequestOpts

func (*RequestOpts) AlwaysReadResponse

func (o *RequestOpts) AlwaysReadResponse() *RequestOpts

func (*RequestOpts) BodyIO

func (o *RequestOpts) BodyIO(reader io.Reader) *RequestOpts

func (*RequestOpts) Cookie

func (o *RequestOpts) Cookie(cookie *http.Cookie) *RequestOpts

func (RequestOpts) Copy

func (o RequestOpts) Copy() *RequestOpts

func (*RequestOpts) Decode

func (o *RequestOpts) Decode(statusCode int, target interface{}) *RequestOpts

func (*RequestOpts) DecodeWith

func (o *RequestOpts) DecodeWith(f func([]byte, interface{}) error) *RequestOpts

func (*RequestOpts) DecodeWithReader

func (o *RequestOpts) DecodeWithReader(f func(io.Reader, interface{}) error) *RequestOpts

func (*RequestOpts) Delete

func (o *RequestOpts) Delete(url string) error

func (*RequestOpts) Describe

func (o *RequestOpts) Describe(description string) *RequestOpts

func (*RequestOpts) Do

func (o *RequestOpts) Do() (result Result)

func (*RequestOpts) DoAfter

func (o *RequestOpts) DoAfter(f func(Result) Result) *RequestOpts

func (*RequestOpts) DoBefore

func (o *RequestOpts) DoBefore(f func(*RequestOpts, *http.Request) error) *RequestOpts

func (*RequestOpts) EncodeWith

func (o *RequestOpts) EncodeWith(f func(interface{}) ([]byte, error)) *RequestOpts

func (*RequestOpts) Get

func (o *RequestOpts) Get(url string) error

func (*RequestOpts) Head

func (o *RequestOpts) Head(url string) error

func (*RequestOpts) JSON

func (o *RequestOpts) JSON() *RequestOpts

func (*RequestOpts) PathParam

func (o *RequestOpts) PathParam(name string, value interface{}) *RequestOpts

func (*RequestOpts) Post

func (o *RequestOpts) Post(url string) error

func (*RequestOpts) Put

func (o *RequestOpts) Put(url string) error

func (*RequestOpts) StrictJSON

func (o *RequestOpts) StrictJSON() *RequestOpts

func (*RequestOpts) WithBaseURL

func (o *RequestOpts) WithBaseURL(url string) *RequestOpts

func (*RequestOpts) WithClient

func (o *RequestOpts) WithClient(client *http.Client) *RequestOpts

func (*RequestOpts) WithContext

func (o *RequestOpts) WithContext(ctx context.Context) *RequestOpts

func (*RequestOpts) WithData

func (o *RequestOpts) WithData(data interface{}) *RequestOpts

func (*RequestOpts) WithMethod

func (o *RequestOpts) WithMethod(m string) *RequestOpts

func (*RequestOpts) WithRaw

func (o *RequestOpts) WithRaw(raw []byte) *RequestOpts

func (*RequestOpts) WithURL

func (o *RequestOpts) WithURL(url string) *RequestOpts

func (*RequestOpts) XML

func (o *RequestOpts) XML() *RequestOpts

type RequestorFuncArg

type RequestorFuncArg func(*RequestOpts)

type Result

type Result struct {
	Request      *http.Request
	Response     *http.Response
	Error        error
	Decoded      bool
	Read         bool
	Body         []byte
	Options      *RequestOpts
	DecodeTarget interface{}
	// contains filtered or unexported fields
}

func (Result) Decode

func (r Result) Decode(statusCode int, target interface{}) Result

func (Result) Done

func (r Result) Done() Result

func (Result) GetError

func (r Result) GetError() error

func (Result) HandleAfter

func (r Result) HandleAfter() Result

func (Result) Raw

func (r Result) Raw() (*http.Response, error)

func (Result) ReadBody

func (r Result) ReadBody() Result

func (Result) Status

func (r Result) Status() (int, error)

func (Result) WillDecode

func (r Result) WillDecode() Result

Jump to

Keyboard shortcuts

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