Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidBase(base string) bool
- func IsValidHostname(host string) bool
- func IsValidScheme(scheme string) bool
- func ParseBaseURL(base string) string
- func ParsePathURL(base string, path string) string
- type BodyProvider
- type BodyResponse
- type Operations
- type Requist
- func (r *Requist) Accept(accept string)
- func (r *Requist) AddHeader(key, value string)
- func (r *Requist) AddQueryParam(key, value string)
- func (r *Requist) Base(base string) *Requist
- func (r *Requist) BodyAsForm(body interface{}) *Requist
- func (r *Requist) BodyAsJSON(body interface{}) *Requist
- func (r *Requist) BodyAsText(body interface{}) *Requist
- func (r *Requist) BodyProvider(body BodyProvider) *Requist
- func (r *Requist) BodyResponse(body BodyResponse) *Requist
- func (r *Requist) CleanQueryParams()
- func (r *Requist) Connect(path string, success, failure interface{}) (*Requist, error)
- func (r *Requist) DelHeader(key string)
- func (r *Requist) DelQueryParam(key string)
- func (r *Requist) Delete(path string, success, failure interface{}) (*Requist, error)
- func (r *Requist) Get(path string, success, failure interface{}) (*Requist, error)
- func (r *Requist) GetBasicAuth() string
- func (r *Requist) Method(method string) *Requist
- func (r *Requist) Options(path string, success, failure interface{}) (*Requist, error)
- func (r *Requist) Patch(path string, success, failure interface{}) (*Requist, error)
- func (r *Requist) Path(path string) *Requist
- func (r *Requist) Post(path string, success, failure interface{}) (*Requist, error)
- func (r *Requist) PrepareRequestURI() (uri string, err error)
- func (r *Requist) Put(path string, success, failure interface{}) (*Requist, error)
- func (r *Requist) Request(success, failure interface{}) (*Requist, error)
- func (r *Requist) SetBasicAuth(username, password string) *Requist
- func (r *Requist) SetClientContext(context context.Context)
- func (r *Requist) SetClientTimeout(timeout time.Duration)
- func (r *Requist) SetClientTransport(transport *http.Transport)
- func (r *Requist) SetHeader(key, value string)
- func (r *Requist) SetQueryParam(key, value string)
- func (r *Requist) StatusCode() int
- func (r *Requist) URI(uri string) *Requist
Constants ¶
const ( // TextContentType is an alias to HTTP text/plain MIME Type TextContentType string = "text/plain" // JSONContentType is an alias to HTTP application/json MIME Type JSONContentType string = "application/json" // FormContentType is an alias to HTTP application/x-www-form-urlencoded MIME Type FormContentType string = "application/x-www-form-urlencoded" )
Variables ¶
var Logger = logger.NewLogger(false)
Logger is the default logs handler
Functions ¶
func IsValidBase ¶ added in v1.2.3
IsValidBase check validity of a base URL
func IsValidHostname ¶ added in v1.2.3
IsValidHostname check validity of a hostname
func IsValidScheme ¶ added in v1.2.3
IsValidScheme check validity of a scheme
func ParseBaseURL ¶ added in v1.2.3
ParseBaseURL check if is valid the base string passed
func ParsePathURL ¶ added in v1.2.3
ParsePathURL check relative path
Types ¶
type BodyProvider ¶
type BodyProvider interface { // ContentType returns the Content-Type of the body. ContentType() string // Body returns the io.Reader body. Body() (io.Reader, error) }
BodyProvider provides Body content for http.Request attachment.
type BodyResponse ¶
type BodyResponse interface { // Decode decodes the response into the value pointed to by v. Accept() string Decode(resp io.Reader, v interface{}) (err error) }
BodyResponse decodes http responses into struct values.
type Operations ¶ added in v1.2.6
type Operations interface { SetClientTransport(transport *http.Transport) SetClientTimeout(timeout time.Duration) SetClientContext(context context.Context) BodyProvider(body BodyProvider) *Requist BodyAsForm(body interface{}) *Requist BodyAsJSON(body interface{}) *Requist BodyAsText(body interface{}) *Requist BodyResponse(body BodyResponse) *Requist Accept(accept string) PrepareRequestURI() (string, error) AddHeader(key, value string) SetHeader(key, value string) DelHeader(key string) AddQueryParam(key, value string) SetQueryParam(key, value string) DelQueryParam(key string) CleanQueryParams() SetBasicAuth(username, password string) *Requist StatusCode() int GetBasicAuth() string Base(base string) *Requist Path(path string) *Requist URI(uri string) *Requist Method(method string) *Requist Get(path string, success, failure interface{}) (*Requist, error) Put(path string, success, failure interface{}) (*Requist, error) Post(path string, success, failure interface{}) (*Requist, error) Patch(path string, success, failure interface{}) (*Requist, error) Delete(path string, success, failure interface{}) (*Requist, error) Options(path string, success, failure interface{}) (*Requist, error) Connect(path string, success, failure interface{}) (*Requist, error) }
Operations interface Define all Methods
type Requist ¶
type Requist struct {
// contains filtered or unexported fields
}
Requist struct Encapsulate an HTTP(S) requests builder and sender
func (*Requist) AddHeader ¶
AddHeader adds the key, value pair in Headers, appending values for existing keys to the key's values. Header keys are canonicalized.
func (*Requist) AddQueryParam ¶
AddQueryParam adds the key, value tuples in QueryParams, appending values for existing keys
func (*Requist) BodyAsForm ¶
BodyAsForm sets the Request's body from a formProvider
func (*Requist) BodyAsJSON ¶
BodyAsJSON sets the Request's body from a jsonProvider
func (*Requist) BodyAsText ¶ added in v1.0.0
BodyAsText sets the Request's body from a textProvider
func (*Requist) BodyProvider ¶
func (r *Requist) BodyProvider(body BodyProvider) *Requist
BodyProvider sets the Request's body provider from original BodyProvider interface{}
func (*Requist) BodyResponse ¶ added in v1.0.0
func (r *Requist) BodyResponse(body BodyResponse) *Requist
BodyResponse sets the response's body
func (*Requist) CleanQueryParams ¶ added in v0.7.0
func (r *Requist) CleanQueryParams()
CleanQueryParams remove all keys from QueryParams
func (*Requist) DelQueryParam ¶
DelQueryParam remove the key from QueryParams
func (*Requist) GetBasicAuth ¶
GetBasicAuth return the auth stored at the Requist class
func (*Requist) PrepareRequestURI ¶ added in v1.2.3
PrepareRequestURI returns actual uri
func (*Requist) SetBasicAuth ¶
SetBasicAuth sets the Authorization header to use HTTP Basic Authentication
func (*Requist) SetClientContext ¶ added in v1.2.6
SetClientContext take transport param and set client HTTP Transport
func (*Requist) SetClientTimeout ¶ added in v1.0.2
SetClientTimeout take timeout param and set client Timeout seconds based
func (*Requist) SetClientTransport ¶ added in v1.1.0
SetClientTransport take transport param and set client HTTP Transport
func (*Requist) SetHeader ¶
SetHeader sets the key, value pair in Headers, replacing existing values associated with key. Header keys are canonicalized.
func (*Requist) SetQueryParam ¶
SetQueryParam set the key, value tuples in params to
func (*Requist) StatusCode ¶
StatusCode return the HTTP StatusCode from last request