Documentation ¶
Index ¶
- type AcceptSlice
- type Handler
- type SimpleWriter
- type Writer
- func NewJSONIndentWriter(prefix string, indent string, options ...WriterOption) Writer
- func NewJSONWriter(options ...WriterOption) Writer
- func NewSimpleWriter(setters ...WriterOption) Writer
- func NewXmlIndentWriter(prefix string, indent string, options ...WriterOption) Writer
- func NewXmlWriter(options ...WriterOption) Writer
- type WriterMapping
- type WriterOption
- type WriterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptSlice ¶
type AcceptSlice []string
AcceptSlice attaches the methods of Interface to []string, sorting in increasing order by its quality value.
func (AcceptSlice) Len ¶
func (p AcceptSlice) Len() int
func (AcceptSlice) Less ¶
func (p AcceptSlice) Less(i, j int) bool
func (AcceptSlice) Swap ¶
func (p AcceptSlice) Swap(i, j int)
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the core of emissione, defining the mapping of accept header values to Writers.
func New ¶
func New(defaultHandler Writer, handlerMapping WriterMapping) *Handler
New returns a user-configured emissione Handler.
type SimpleWriter ¶
type SimpleWriter struct {
// contains filtered or unexported fields
}
SimpleWriter is a simple implementation of emissiones Writer interface, delegating writing duty to a specific marshaller, and setting the appropriate content type header.
func (SimpleWriter) Write ¶
func (writer SimpleWriter) Write(w http.ResponseWriter, i interface{}) error
type Writer ¶
type Writer interface {
Write(w http.ResponseWriter, i interface{}) error
}
Writer is a handler used by emissione, to deliver a specific output to the client.
func NewJSONIndentWriter ¶
func NewJSONIndentWriter(prefix string, indent string, options ...WriterOption) Writer
NewJSONIndentWriter creates a new SimpleWriter, marshalling via json.MarshalIndent.
func NewJSONWriter ¶
func NewJSONWriter(options ...WriterOption) Writer
NewJSONWriter creates a new SimpleWriter, marshalling via json.Marshal.
func NewSimpleWriter ¶
func NewSimpleWriter(setters ...WriterOption) Writer
NewSimpleWriter instantiates a new SimpleWriter.
See the documentation for WriterOption for configuration options.
func NewXmlIndentWriter ¶
func NewXmlIndentWriter(prefix string, indent string, options ...WriterOption) Writer
NewXmlIndentWriter creates a new SimpleWriter, marshalling via xml.MarshalIndent.
func NewXmlWriter ¶
func NewXmlWriter(options ...WriterOption) Writer
NewXmlWriter creates a new SimpleWriter, marshalling via xml.Marshal.
type WriterMapping ¶
WriterMapping is a convenience alias for map[string]Writer
type WriterOption ¶
type WriterOption func(*WriterOptions)
WriterOption is functional option to WriterOptions.
func ContentType ¶
func ContentType(contentType string) WriterOption
ContentType sets the content-type string, which will be set as the header of the same name.
func MarshallMethod ¶
func MarshallMethod(method func(v interface{}) ([]byte, error)) WriterOption
MarshallMethod defines the marshalling method used by a SimpleWriter to marshall output objects.
type WriterOptions ¶
WriterOptions is the option-wrapper for defining the workings of a Writer.