Documentation
¶
Index ¶
- Constants
- func Encode(data map[string]interface{}, dataformat string) (string, error)
- func RegisterDataFormat(dataformat DataFormat)
- type DataFormat
- type Decoded
- type Form
- type JSON
- type MultiPartForm
- func (m *MultiPartForm) Decode(data string) (map[string]interface{}, error)
- func (m *MultiPartForm) Encode(data map[string]interface{}) (string, error)
- func (m *MultiPartForm) IsType(data string) bool
- func (m *MultiPartForm) Name() string
- func (m *MultiPartForm) ParseBoundary(contentType string) error
- type Raw
- type XML
Constants ¶
View Source
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" )
Variables ¶
This section is empty.
Functions ¶
func RegisterDataFormat ¶
func RegisterDataFormat(dataformat DataFormat)
RegisterEncoder registers an encoder
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 map[string]interface{}) (string, error)
// Decode decodes the data from a format
Decode(input string) (map[string]interface{}, 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 map[string]interface{}
}
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 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) (map[string]interface{}, error)
Decode decodes the data from MultiPartForm format
func (*MultiPartForm) Encode ¶
func (m *MultiPartForm) Encode(data map[string]interface{}) (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{}
Click to show internal directories.
Click to hide internal directories.