Documentation ¶
Index ¶
- Constants
- func Encode(data KV, dataformat string) (string, error)
- func RegisterDataFormat(dataformat DataFormat)
- func ToMap(m *mapsutil.OrderedMap[string, any]) map[string]interface{}
- func ToOrderedMap(data map[string]interface{}) *mapsutil.OrderedMap[string, any]
- type DataFormat
- type Decoded
- type Form
- type JSON
- type KV
- type MultiPartForm
- type Raw
- type XML
Constants ¶
const ( // JSONDataFormat is the name of the JSON data format JSONDataFormat = "json" // XMLDataFormat is the name of the XML data format XMLDataFormat = "xml" // RawDataFormat is the name of the Raw data format RawDataFormat = "raw" // FormDataFormat is the name of the Form data format FormDataFormat = "form" // MultiPartFormDataFormat is the name of the MultiPartForm data format MultiPartFormDataFormat = "multipart/form-data" )
const ( // DefaultKey is the key i.e used when given // data is not of k-v type DefaultKey = "value" )
Variables ¶
This section is empty.
Functions ¶
func RegisterDataFormat ¶
func RegisterDataFormat(dataformat DataFormat)
RegisterEncoder registers an encoder
func ToMap ¶
func ToMap(m *mapsutil.OrderedMap[string, any]) map[string]interface{}
ToMap converts the ordered map to a map
func ToOrderedMap ¶
func ToOrderedMap(data map[string]interface{}) *mapsutil.OrderedMap[string, any]
ToOrderedMap converts the map to an ordered map
Types ¶
type DataFormat ¶
type DataFormat interface { // IsType returns true if the data is of the type IsType(data string) bool // Name returns the name of the encoder Name() string // Encode encodes the data into a format Encode(data KV) (string, error) // Decode decodes the data from a format Decode(input string) (KV, error) }
DataFormat is an interface for encoding and decoding
type Decoded ¶
type Decoded struct { // DataFormat is the data format DataFormat string // Data is the decoded data Data KV }
Decoded is a decoded data format
type Form ¶
type Form struct{}
type JSON ¶
type JSON struct{}
JSON is a JSON encoder
For now JSON only supports objects as the root data type and not arrays
TODO: Support arrays + other JSON oddities by adding more attirbutes to the map[string]interface{}
type KV ¶
type KV struct { Map map[string]interface{} OrderedMap *mapsutil.OrderedMap[string, any] }
KV is a key-value struct that is implemented or used by fuzzing package to represent a key-value pair sometimes order or key-value pair is important (query params) so we use ordered map to represent the data if it's not important/significant (ex: json,xml) we use map this also allows us to iteratively implement ordered map
func KVOrderedMap ¶
func KVOrderedMap(data *mapsutil.OrderedMap[string, any]) KV
KVOrderedMap returns a new KV struct with the given ordered map
func (*KV) IsOrderedMap ¶
IsOrderedMap returns true if the KV struct is an ordered map
type MultiPartForm ¶
type MultiPartForm struct {
// contains filtered or unexported fields
}
func NewMultiPartForm ¶
func NewMultiPartForm() *MultiPartForm
NewMultiPartForm returns a new MultiPartForm encoder
func (*MultiPartForm) Decode ¶
func (m *MultiPartForm) Decode(data string) (KV, error)
Decode decodes the data from MultiPartForm format
func (*MultiPartForm) Encode ¶
func (m *MultiPartForm) Encode(data KV) (string, error)
Encode encodes the data into MultiPartForm format
func (*MultiPartForm) IsType ¶
func (m *MultiPartForm) IsType(data string) bool
IsType returns true if the data is MultiPartForm encoded
func (*MultiPartForm) Name ¶
func (m *MultiPartForm) Name() string
Name returns the name of the encoder
func (*MultiPartForm) ParseBoundary ¶
func (m *MultiPartForm) ParseBoundary(contentType string) error
ParseBoundary parses the boundary from the content type
type Raw ¶
type Raw struct{}