Documentation
¶
Index ¶
Constants ¶
View Source
const MimeJSON = "application/json"
View Source
const MimeXML = "application/xml"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContentNegotiator ¶
type ContentNegotiator struct {
DefaultEncoder Encoder
ResponseWriter http.ResponseWriter
// contains filtered or unexported fields
}
ContentNegotiator is a Neotiator that supports a fallback/default encoder as well as dynamically adding encoders
func NewContentNegotiator ¶
func NewContentNegotiator(defaultEncoder Encoder, responseWriter http.ResponseWriter) *ContentNegotiator
NewContentNegotiator creates a basic ContentNegotiator with out any attached encoders
func NewJsonXmlContentNegotiator ¶
func NewJsonXmlContentNegotiator(defaultEncoder Encoder, responseWriter http.ResponseWriter, prettyPrint bool) *ContentNegotiator
NewJsonXmlContentNegotiator creates a basic ContentNegotiator and attaches a JSON and an XML encoder to it.
func (*ContentNegotiator) AddEncoder ¶
func (cn *ContentNegotiator) AddEncoder(mimeType string, enc Encoder)
AddEncoder registers a mimetype and its encoder to be used if a client requests that mimetype
type JsonEncoder ¶
type JsonEncoder struct {
PrettyPrint bool
}
func (JsonEncoder) ContentType ¶
func (js JsonEncoder) ContentType() string
func (JsonEncoder) Encode ¶
func (je JsonEncoder) Encode(data interface{}) ([]byte, error)
type Negotiator ¶
A Negotiator can Negotiate to determine what content type to convert a struct into for client consumption
type XmlEncoder ¶
type XmlEncoder struct {
PrettyPrint bool
}
func (XmlEncoder) ContentType ¶
func (xe XmlEncoder) ContentType() string
func (XmlEncoder) Encode ¶
func (xe XmlEncoder) Encode(data interface{}) ([]byte, error)
Click to show internal directories.
Click to hide internal directories.