component

package
v3.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
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

Components is a list of all available components

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is a error raised when a key is not found

View Source
var ErrSetValue = errors.New("could not set value")

ErrSetValue is a error raised when a value cannot be set

Functions

func IsErrSetValue

func IsErrSetValue(err error) bool

func IsTypedSlice added in v3.2.3

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 NewBody

func NewBody() *Body

NewBody creates a new body component

func (*Body) Clone added in v3.2.3

func (b *Body) Clone() Component

func (*Body) Delete

func (b *Body) Delete(key string) error

Delete deletes a key from the component

func (*Body) Iterate

func (b *Body) Iterate(callback func(key string, value interface{}) error) (errx error)

Iterate iterates through the component

func (*Body) Name

func (b *Body) Name() string

Name returns the name of the component

func (*Body) Parse

func (b *Body) Parse(req *retryablehttp.Request) (bool, error)

Parse parses the component and returns the parsed component

func (*Body) Rebuild

func (b *Body) Rebuild() (*retryablehttp.Request, error)

Rebuild returns a new request with the component rebuilt

func (*Body) SetValue

func (b *Body) SetValue(key string, value string) error

SetValue sets a value in the 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

func New

func New(componentType string) Component

New creates a new component for a componentType

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

Cookie is a component for a request cookie

func NewCookie

func NewCookie() *Cookie

NewCookie creates a new cookie component

func (*Cookie) Clone added in v3.2.3

func (c *Cookie) Clone() Component

Clone clones current state of this component

func (*Cookie) Delete

func (c *Cookie) Delete(key string) error

Delete deletes a key from the component

func (*Cookie) Iterate

func (c *Cookie) Iterate(callback func(key string, value interface{}) error) (err error)

Iterate iterates through the component

func (*Cookie) Name

func (c *Cookie) Name() string

Name returns the name of the component

func (*Cookie) Parse

func (c *Cookie) Parse(req *retryablehttp.Request) (bool, error)

Parse parses the component and returns the parsed component

func (*Cookie) Rebuild

func (c *Cookie) Rebuild() (*retryablehttp.Request, error)

Rebuild returns a new request with the component rebuilt

func (*Cookie) SetValue

func (c *Cookie) SetValue(key string, value string) error

SetValue sets a value in the component for a key

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

Header is a component for a request header

func NewHeader

func NewHeader() *Header

NewHeader creates a new header component

func (*Header) Clone added in v3.2.3

func (q *Header) Clone() Component

Clones current state of this component

func (*Header) Delete

func (q *Header) Delete(key string) error

Delete deletes a key from the component

func (*Header) Iterate

func (q *Header) Iterate(callback func(key string, value interface{}) error) (errx error)

Iterate iterates through the component

func (*Header) Name

func (q *Header) Name() string

Name returns the name of the component

func (*Header) Parse

func (q *Header) Parse(req *retryablehttp.Request) (bool, error)

Parse parses the component and returns the parsed component

func (*Header) Rebuild

func (q *Header) Rebuild() (*retryablehttp.Request, error)

Rebuild returns a new request with the component rebuilt

func (*Header) SetValue

func (q *Header) SetValue(key string, value string) error

SetValue sets a value in the component for a key

type Path

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

Path is a component for a request Path

func NewPath

func NewPath() *Path

NewPath creates a new URL component

func (*Path) Clone added in v3.2.3

func (q *Path) Clone() Component

Clones current state to a new component

func (*Path) Delete

func (q *Path) Delete(key string) error

Delete deletes a key from the component

func (*Path) Iterate

func (q *Path) Iterate(callback func(key string, value interface{}) error) (err error)

Iterate iterates through the component

func (*Path) Name

func (q *Path) Name() string

Name returns the name of the component

func (*Path) Parse

func (q *Path) Parse(req *retryablehttp.Request) (bool, error)

Parse parses the component and returns the parsed component

func (*Path) Rebuild

func (q *Path) Rebuild() (*retryablehttp.Request, error)

Rebuild returns a new request with the component rebuilt

func (*Path) SetValue

func (q *Path) SetValue(key string, value string) error

SetValue sets a value in the component for a key

type Query

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

Query is a component for a request query

func NewQuery

func NewQuery() *Query

NewQuery creates a new query component

func (*Query) Clone added in v3.2.3

func (q *Query) Clone() Component

Clones current state to a new component

func (*Query) Delete

func (q *Query) Delete(key string) error

Delete deletes a key from the component

func (*Query) Iterate

func (q *Query) Iterate(callback func(key string, value interface{}) error) (errx error)

Iterate iterates through the component

func (*Query) Name

func (q *Query) Name() string

Name returns the name of the component

func (*Query) Parse

func (q *Query) Parse(req *retryablehttp.Request) (bool, error)

Parse parses the component and returns the parsed component

func (*Query) Rebuild

func (q *Query) Rebuild() (*retryablehttp.Request, error)

Rebuild returns a new request with the component rebuilt

func (*Query) SetValue

func (q *Query) SetValue(key string, value string) error

SetValue sets a value in the component for a key

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 NewValue

func NewValue(data string) *Value

NewValue returns a new value component

func (*Value) Clone added in v3.2.3

func (v *Value) Clone() *Value

Clones current state of this value

func (*Value) Delete

func (v *Value) Delete(key string) bool

Delete removes a key from the parsed value

func (*Value) Encode

func (v *Value) Encode() (string, error)

Encode encodes the value into a string using the dataformat and encoding

func (*Value) Parsed

func (v *Value) Parsed() dataformat.KV

Parsed returns the parsed value

func (*Value) SetParsed

func (v *Value) SetParsed(data dataformat.KV, dataFormat string)

SetParsed sets the parsed value map

func (*Value) SetParsedValue

func (v *Value) SetParsedValue(key string, value string) bool

SetParsedValue sets the parsed value for a key in the parsed map

func (*Value) String

func (v *Value) String() string

String returns the string representation of the value

Jump to

Keyboard shortcuts

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