httpsimple

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 13 Imported by: 33

Documentation

Index

Constants

View Source
const (
	BodyTypeForm = "form"
	BodyTypeJSON = "json"
	BodyTypeXML  = "xml"
)

Variables

This section is empty.

Functions

func Do

func Do(req SimpleRequest) (*http.Response, error)

func DoMore added in v0.45.0

func DoMore(req SimpleRequest) ([]byte, *http.Response, error)

func DoSimple added in v0.45.0

func DoSimple(client *http.Client, httpMethod, requrl string, headers map[string][]string, body []byte) (*http.Response, error)

Types

type SimpleClient

type SimpleClient struct {
	BaseURL    string
	HTTPClient *http.Client
}

SimpleClient provides a simple interface to making HTTP requests using `net/http`.

func NewSimpleClient

func NewSimpleClient(httpClient *http.Client, baseURL string) SimpleClient

func (*SimpleClient) Do

func (sc *SimpleClient) Do(req SimpleRequest) (*http.Response, error)

func (*SimpleClient) DoUnmarshalJSON added in v0.45.0

func (sc *SimpleClient) DoUnmarshalJSON(req SimpleRequest, resBody any) ([]byte, *http.Response, error)

func (*SimpleClient) Get

func (sc *SimpleClient) Get(reqURL string) (*http.Response, error)

type SimpleRequest

type SimpleRequest struct {
	Method        string
	URL           string
	Query         map[string][]string
	Headers       map[string][]string
	Body          any
	BodyType      string
	AddXMLDocType bool // only used if `Body` is a struct.
}

func (*SimpleRequest) BodyBytes

func (req *SimpleRequest) BodyBytes() ([]byte, error)

func (*SimpleRequest) Inflate

func (req *SimpleRequest) Inflate()

Jump to

Keyboard shortcuts

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