Documentation ¶
Index ¶
- func DecodeForm(r io.ReadCloser, v interface{}) error
- func DecodeJSON(r io.Reader, v interface{}) error
- func DecodeXML(r io.Reader, v interface{}) error
- func EncodeForm(w http.ResponseWriter, obj interface{}) error
- func EncodeJSON(w http.ResponseWriter, obj interface{}) error
- func EncodeXML(w http.ResponseWriter, obj interface{}) error
- func GetLogger(r *http.Request) log.Logger
- type Binder
- type Content
- type ContentType
- type Decoder
- type Encoder
- type Reactor
- type Renderer
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeForm ¶
func DecodeForm(r io.ReadCloser, v interface{}) error
DecodeForm decodes a object from Form reader
func DecodeJSON ¶
DecodeJSON decodes a object from JSON reader
func EncodeForm ¶
func EncodeForm(w http.ResponseWriter, obj interface{}) error
EncodeForm marshals 'obj' to URL encoded data, and setting the Content-Type as application/x-www-form-urlencoded.
func EncodeJSON ¶
func EncodeJSON(w http.ResponseWriter, obj interface{}) error
EncodeJSON marshals 'obj' to JSON, automatically escaping HTML and setting the Content-Type as application/json.
func EncodeXML ¶
func EncodeXML(w http.ResponseWriter, obj interface{}) error
EncodeXML marshals 'obj' to JSON, setting the Content-Type as application/xml. It will automatically prepend a generic XML header (see encoding/xml.Header) if one is not found in the first 100 bytes of 'v'.
Types ¶
type Content ¶
type Content struct { Type ContentType Params map[string]string }
Content represents the content type
func ParseContent ¶
ParseContent parse the content type
type ContentType ¶
type ContentType int
ContentType is an enumeration of common HTTP content types.
const ( ContentTypeUnknown ContentType = iota ContentTypePlainText ContentTypeHTML ContentTypeJSON ContentTypeXML ContentTypeForm ContentTypeEventStream )
ContentTypes handled by this package.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes a request
func (*Decoder) SetContentType ¶
func (d *Decoder) SetContentType(kind ContentType)
SetContentType overrides the Content-Type attribute
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder encodes the request
func NewEncoder ¶
func NewEncoder(w http.ResponseWriter, r *http.Request) *Encoder
NewEncoder creates a new encoder
func (*Encoder) SetContentType ¶
func (e *Encoder) SetContentType(kind ContentType)
SetContentType overrides the Content-Type attribute
type Reactor ¶
type Reactor struct {
// contains filtered or unexported fields
}
Reactor works with http response and request
func NewReactor ¶
func NewReactor(w http.ResponseWriter, r *http.Request) *Reactor
NewReactor creates a new reactor
func (*Reactor) RenderWith ¶
RenderWith renders the response with code
type Renderer ¶
type Renderer interface {
Render(w http.ResponseWriter, r *http.Request) error
}
Renderer interface for managing response payloads.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates an object
func NewValidator ¶
NewValidator creates a new validator