Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder interface {
// WithEncoder sets default content-type and PayloadEncoder that serializes
// objects into io.Writer in that content-type.
WithEncoder(ct string, encFunc PayloadEncoder) Builder
// WithErrorMapper registers mapping function that can customize error response
WithErrorMapper(mapper ErrorMapper) Builder
// Build creates new Interface using current state of this Builder.
Build() Interface
}
func NewBuilder ¶
func NewBuilder() Builder
type ErrorMapper ¶
type ErrorMapper func(w http.ResponseWriter, err error) bool
ErrorMapper is function that could customize serialization of error instance. All registered mappers all enumerated in order they were registered when instance of error is to be sent. First mapper that returns true will terminate enumeration and process will end.
type Interface ¶
type Interface interface {
// SendWithStatus sends object back to client with given status code.
// If object to be send is error, then registered ErrorMappers can influence output instead.
SendWithStatus(w http.ResponseWriter, v interface{}, status int)
// SendBytes sends raw bytes to output, assuming content-type of current encoder
SendBytes(w http.ResponseWriter, data []byte)
}
func DefaultOutput ¶
func DefaultOutput() Interface
type PayloadEncoder ¶
PayloadEncoder is responsible to serialize object to io.Writer
Click to show internal directories.
Click to hide internal directories.