httpclient

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthError added in v0.0.3

func IsAuthError(err error) bool

func NewHttpError added in v0.0.3

func NewHttpError(message string, cause error) error

func NewHttpErrorWithStatus added in v0.0.3

func NewHttpErrorWithStatus(message string, status string, statusCode int) error

Types

type CookieHelper

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

func (*CookieHelper) CookiesSaved

func (c *CookieHelper) CookiesSaved() (cookiesExist bool)

func (*CookieHelper) ExtractCSRF

func (c *CookieHelper) ExtractCSRF(jar http.CookieJar, baseDomain string) (csrf string)

func (*CookieHelper) ExtractLoginFormInputsCSRF

func (c *CookieHelper) ExtractLoginFormInputsCSRF(formHtml string) (formData *url.Values)

func (*CookieHelper) LoadCookies

func (c *CookieHelper) LoadCookies(jar http.CookieJar, baseDomain string) (err error)

func (*CookieHelper) SaveCookies

func (c *CookieHelper) SaveCookies(jar http.CookieJar, baseDomain string) (err error)
type Header struct {
	Key   string
	Value string
}

type Headers

type Headers []Header

type HttpClient

type HttpClient struct {
	*http.Client
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient() *HttpClient

func (*HttpClient) GetCookieJar

func (httpClient *HttpClient) GetCookieJar() http.CookieJar

func (*HttpClient) ResetCookieJar added in v0.0.3

func (httpClient *HttpClient) ResetCookieJar()

func (*HttpClient) RestGET

func (httpClient *HttpClient) RestGET(url string, rqHeaders *Headers, rs any) (err error)

func (*HttpClient) RestPOST

func (httpClient *HttpClient) RestPOST(url string, rqHeaders *Headers, rq any, rs any) (err error)

func (*HttpClient) SimpleGET

func (httpClient *HttpClient) SimpleGET(url string, rqHeaders *Headers) (rs *Response, err error)

func (*HttpClient) SimplePOST

func (httpClient *HttpClient) SimplePOST(url string, rqHeaders *Headers, formData *url.Values) (rs *Response, err error)

func (*HttpClient) WithRequestLogger

func (httpClient *HttpClient) WithRequestLogger(f func(rq *http.Request, rqBody []byte)) *HttpClient

func (*HttpClient) WithResponseLogger

func (httpClient *HttpClient) WithResponseLogger(f func(rq *http.Request, rqBody []byte, rs *http.Response, rsBody []byte, err error, start time.Time)) *HttpClient

func (*HttpClient) WithTimeout

func (httpClient *HttpClient) WithTimeout(duration time.Duration) *HttpClient

type HttpError added in v0.0.3

type HttpError struct {
	Status     string
	StatusCode int
	// contains filtered or unexported fields
}

func (*HttpError) Error added in v0.0.3

func (he *HttpError) Error() string

func (*HttpError) Unwrap added in v0.0.3

func (he *HttpError) Unwrap() error

type ICookieHelper

type ICookieHelper interface {
	CookiesSaved() (cookiesExist bool)
	SaveCookies(jar http.CookieJar, baseDomain string) (err error)
	LoadCookies(jar http.CookieJar, baseDomain string) (err error)
	ExtractCSRF(jar http.CookieJar, baseDomain string) (csrf string)
	ExtractLoginFormInputsCSRF(formHtml string) (formData *url.Values)
}

func NewCookieHelper

func NewCookieHelper(filePath string) ICookieHelper

type IHttpClient

type IHttpClient interface {
	RestGET(url string, rqHeaders *Headers, rs any) (err error)          // rs by ref (no generic in types)
	RestPOST(url string, rqHeaders *Headers, rq any, rs any) (err error) // rs by ref (no generic in types)
	SimpleGET(url string, rqHeaders *Headers) (rs *Response, err error)
	SimplePOST(url string, rqHeaders *Headers, formData *url.Values) (rs *Response, err error)
	GetCookieJar() (jar http.CookieJar)
	ResetCookieJar()
}

type Response

type Response struct {
	Status   int
	Body     string
	Redirect string
}

Jump to

Keyboard shortcuts

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