Documentation
¶
Overview ¶
Package serializer provides an interface to read from request body or write to response body. Can be used for reading/writing JSON, XML, MessagePack, etc.
Currently the supported ones are JSON and XML.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Serializer ¶
type Serializer interface {
// Write writes object with the given indent to response body.
Write(w http.ResponseWriter, in any, indent string)
// Read reads request body and store it in the given object.
Read(req *http.Request, out any) error
}
Serializer is the interface for reading from request body or writing to response body.
It can be implemented to read/write custom JSON/XML serializers.
func NewJSONSerializer ¶
func NewJSONSerializer() Serializer
NewJSONSerializer returns a new JSON serializer.
func NewXMLSerializer ¶
func NewXMLSerializer() Serializer
NewXMLSerializer returns a new XML serializer.
Click to show internal directories.
Click to hide internal directories.