Documentation
¶
Overview ¶
Package encoder provides response encoding functionality for the context package. Feed encoder interface implementation into the context object when you reset it, and it will be used to encode response.
Typical usage:
enc := encoder.JSON ctx.Reset(..., enc, ...) // ... if err := ctx.Encode(w, http.StatusOK, data); err != nil { ctx.Logger().Error(err.Error()) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // HTML encoder writes provided data into response as html text. HTML = Func(encodeHTML) )
View Source
var ( // JSON encoder writes provided data into response as json payload. JSON = Func(encodeJSON) )
View Source
var ( // Plain encoder writes provided data into response as plain text. Plain = Func(encodePlain) )
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder interface {
Encode(http.ResponseWriter, int, interface{}) error
}
Encoder interface that encodes arbitrary data and writes the result into http response.
Click to show internal directories.
Click to hide internal directories.