webtools

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHttpClient

func GetHttpClient(opts ...ClientOpts) *http.Client

Types

type Authorization

type Authorization interface {
	Apply(*RestRequest) *RestRequest
}

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

func (*BasicAuth) Apply

func (ba *BasicAuth) Apply(req *RestRequest) *RestRequest

type ClientOpts

type ClientOpts interface {
	Apply(*http.Client)
}

type MultipartField

type MultipartField struct {
	Key string
	// contains filtered or unexported fields
}

func NewMultipartField

func NewMultipartField(key string) *MultipartField

func (*MultipartField) AddToWriter

func (m *MultipartField) AddToWriter(w *multipart.Writer) error

func (*MultipartField) WithBytesValue

func (m *MultipartField) WithBytesValue(value []byte) *MultipartField

func (*MultipartField) WithContentType

func (m *MultipartField) WithContentType(contentType string) *MultipartField

func (*MultipartField) WithFilename

func (m *MultipartField) WithFilename(filename string) *MultipartField

func (*MultipartField) WithPipe

func (m *MultipartField) WithPipe(pipe *io.PipeReader) *MultipartField

func (*MultipartField) WithReaderValue

func (m *MultipartField) WithReaderValue(value io.Reader) *MultipartField

func (*MultipartField) WithStringValue

func (m *MultipartField) WithStringValue(value string) *MultipartField

type RequestMethod

type RequestMethod string
const (
	GET    RequestMethod = "GET"
	POST   RequestMethod = "POST"
	PUT    RequestMethod = "PUT"
	DELETE RequestMethod = "DELETE"
	PATCH  RequestMethod = "PATCH"
)

type RestRequest

type RestRequest struct {
	Url    string
	Method RequestMethod

	Headers map[string]string

	BodyReader io.Reader
	// contains filtered or unexported fields
}

func DeleteRequest

func DeleteRequest(url string) *RestRequest

func GetRequest

func GetRequest(url string) *RestRequest

func NewRequest

func NewRequest(method RequestMethod, url string) *RestRequest

func PatchRequest

func PatchRequest(url string) *RestRequest

func PostRequest

func PostRequest(url string) *RestRequest

func PutRequest

func PutRequest(url string) *RestRequest

func (*RestRequest) Execute

func (r *RestRequest) Execute() (*RestResponse, error)

func (*RestRequest) Validate

func (r *RestRequest) Validate() error

func (*RestRequest) WithAuthorization

func (r *RestRequest) WithAuthorization(auth Authorization) *RestRequest

func (*RestRequest) WithBodyBytes

func (r *RestRequest) WithBodyBytes(body []byte) *RestRequest

func (*RestRequest) WithBodyString

func (r *RestRequest) WithBodyString(body string) *RestRequest

func (*RestRequest) WithHeader

func (r *RestRequest) WithHeader(key, value string) *RestRequest

func (*RestRequest) WithHeaders

func (r *RestRequest) WithHeaders(headers map[string]string) *RestRequest

func (*RestRequest) WithJsonBody

func (r *RestRequest) WithJsonBody(body interface{}, contentType *string) *RestRequest

func (*RestRequest) WithMultipartFormBody

func (r *RestRequest) WithMultipartFormBody(body []MultipartField) *RestRequest

func (*RestRequest) WithQueryParams

func (r *RestRequest) WithQueryParams(params map[string]string) *RestRequest

func (*RestRequest) WithUrlencodedFormBody

func (r *RestRequest) WithUrlencodedFormBody(body interface{}, contentType *string) *RestRequest

func (*RestRequest) WithXmlBody

func (r *RestRequest) WithXmlBody(body interface{}, contentType *string) *RestRequest

type RestResponse

type RestResponse struct {
	StatusCode int
	Headers    map[string][]string
	Response   *http.Response
	// contains filtered or unexported fields
}

func (*RestResponse) BodyAsBytes

func (r *RestResponse) BodyAsBytes() ([]byte, error)

func (*RestResponse) BodyAsString

func (r *RestResponse) BodyAsString() (string, error)

func (*RestResponse) Close

func (r *RestResponse) Close()

func (*RestResponse) UnmarshalJsonBody

func (r *RestResponse) UnmarshalJsonBody(v interface{}) error

func (*RestResponse) UnmarshalXmlBody

func (r *RestResponse) UnmarshalXmlBody(v interface{}) error

type WithClientCertificate

type WithClientCertificate tls.Certificate

func (*WithClientCertificate) Apply

func (wtc *WithClientCertificate) Apply(client *http.Client)

Jump to

Keyboard shortcuts

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