Documentation
¶
Index ¶
- Constants
- Variables
- func IsErrSetValue(err error) bool
- func IsTypedSlice(v interface{}) ([]interface{}, bool)
- type Body
- func (b *Body) Clone() Component
- func (b *Body) Delete(key string) error
- func (b *Body) Iterate(callback func(key string, value interface{}) error) (errx error)
- func (b *Body) Name() string
- func (b *Body) Parse(req *retryablehttp.Request) (bool, error)
- func (b *Body) Rebuild() (*retryablehttp.Request, error)
- func (b *Body) SetValue(key string, value string) error
- type Component
- type Cookie
- func (c *Cookie) Clone() Component
- func (c *Cookie) Delete(key string) error
- func (c *Cookie) Iterate(callback func(key string, value interface{}) error) (err error)
- func (c *Cookie) Name() string
- func (c *Cookie) Parse(req *retryablehttp.Request) (bool, error)
- func (c *Cookie) Rebuild() (*retryablehttp.Request, error)
- func (c *Cookie) SetValue(key string, value string) error
- type Header
- func (q *Header) Clone() Component
- func (q *Header) Delete(key string) error
- func (q *Header) Iterate(callback func(key string, value interface{}) error) (errx error)
- func (q *Header) Name() string
- func (q *Header) Parse(req *retryablehttp.Request) (bool, error)
- func (q *Header) Rebuild() (*retryablehttp.Request, error)
- func (q *Header) SetValue(key string, value string) error
- type Path
- func (q *Path) Clone() Component
- func (q *Path) Delete(key string) error
- func (q *Path) Iterate(callback func(key string, value interface{}) error) (err error)
- func (q *Path) Name() string
- func (q *Path) Parse(req *retryablehttp.Request) (bool, error)
- func (q *Path) Rebuild() (*retryablehttp.Request, error)
- func (q *Path) SetValue(key string, value string) error
- type Query
- func (q *Query) Clone() Component
- func (q *Query) Delete(key string) error
- func (q *Query) Iterate(callback func(key string, value interface{}) error) (errx error)
- func (q *Query) Name() string
- func (q *Query) Parse(req *retryablehttp.Request) (bool, error)
- func (q *Query) Rebuild() (*retryablehttp.Request, error)
- func (q *Query) SetValue(key string, value string) error
- type Value
- func (v *Value) Clone() *Value
- func (v *Value) Delete(key string) bool
- func (v *Value) Encode() (string, error)
- func (v *Value) Parsed() dataformat.KV
- func (v *Value) SetParsed(data dataformat.KV, dataFormat string)
- func (v *Value) SetParsedValue(key, value string) bool
- func (v *Value) String() string
Constants ¶
const ( // RequestBodyComponent is the name of the request body component RequestBodyComponent = "body" // RequestQueryComponent is the name of the request query component RequestQueryComponent = "query" // RequestPathComponent is the name of the request url component RequestPathComponent = "path" // RequestHeaderComponent is the name of the request header component RequestHeaderComponent = "header" // RequestCookieComponent is the name of the request cookie component RequestCookieComponent = "cookie" )
Variables ¶
var Components = []string{ RequestBodyComponent, RequestQueryComponent, RequestPathComponent, RequestHeaderComponent, RequestCookieComponent, }
Components is a list of all available components
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is a error raised when a key is not found
var ErrSetValue = errors.New("could not set value")
ErrSetValue is a error raised when a value cannot be set
Functions ¶
func IsErrSetValue ¶
func IsTypedSlice ¶
func IsTypedSlice(v interface{}) ([]interface{}, bool)
In go, []int, []string are not implictily converted to []interface{} when using type assertion and they need to be handled separately.
Types ¶
type Body ¶
type Body struct {
// contains filtered or unexported fields
}
Body is a component for a request body
func (*Body) Parse ¶
func (b *Body) Parse(req *retryablehttp.Request) (bool, error)
Parse parses the component and returns the parsed component
type Component ¶
type Component interface {
// Name returns the name of the component
Name() string
// Parse parses the component and returns the
// parsed component
Parse(req *retryablehttp.Request) (bool, error)
// Iterate iterates over all values of a component
// ex in case of query component, it will iterate over each query parameter
// depending on the rule if mode is single
// request is rebuilt for each value in this callback
// and in case of multiple, request will be rebuilt after iteration of all values
Iterate(func(key string, value interface{}) error) error
// SetValue sets a value in the component
// for a key
//
// After calling setValue for mutation, the value must be
// called again so as to reset the body to its original state.
SetValue(key string, value string) error
// Delete deletes a key from the component
// If it is applicable
Delete(key string) error
// Rebuild returns a new request with the
// component rebuilt
Rebuild() (*retryablehttp.Request, error)
// Clones current state of this component
Clone() Component
}
Component is a component for a request
type Cookie ¶
type Cookie struct {
// contains filtered or unexported fields
}
Cookie is a component for a request cookie
func (*Cookie) Parse ¶
func (c *Cookie) Parse(req *retryablehttp.Request) (bool, error)
Parse parses the component and returns the parsed component
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header is a component for a request header
func (*Header) Parse ¶
func (q *Header) Parse(req *retryablehttp.Request) (bool, error)
Parse parses the component and returns the parsed component
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is a component for a request Path
func (*Path) Parse ¶
func (q *Path) Parse(req *retryablehttp.Request) (bool, error)
Parse parses the component and returns the parsed component
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a component for a request query
func (*Query) Parse ¶
func (q *Query) Parse(req *retryablehttp.Request) (bool, error)
Parse parses the component and returns the parsed component
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a value component containing a single parameter for the component
It is a type of container that is used to represent all the data values that are used in a request.
func (*Value) SetParsed ¶
func (v *Value) SetParsed(data dataformat.KV, dataFormat string)
SetParsed sets the parsed value map
func (*Value) SetParsedValue ¶
SetParsedValue sets the parsed value for a key in the parsed map