Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCodeUnmarshalRequestBodyFailed *string ErrCodeRequestBodyFieldError *string )
View Source
var ( ErrCodeReadBodyFailed *string ErrCodeNilDestination *string )
View Source
var ( ErrNilEncoder = errors.New("json encoder is nil") ErrNilDecoder = errors.New("json decoder is nil") ErrUnmarshalBodyFailed = errors.New("failed to unmarshal json body") )
View Source
var (
ErrCodeMarshalResponseBodyFailed *string
)
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder interface {
Decode(
w http.ResponseWriter,
r *http.Request,
dest interface{},
) (err error)
}
Decoder interface
type DefaultDecoder ¶
type DefaultDecoder struct {
// contains filtered or unexported fields
}
DefaultDecoder struct
func NewDefaultDecoder ¶
func NewDefaultDecoder( mode *goflagsmode.Flag, encoder Encoder, ) (*DefaultDecoder, error)
NewDefaultDecoder creates a new JSON decoder
func (*DefaultDecoder) Decode ¶
func (d *DefaultDecoder) Decode( w http.ResponseWriter, r *http.Request, dest interface{}, ) (err error)
Decode decodes the JSON request body and stores it in the destination
type DefaultEncoder ¶
type DefaultEncoder struct {
// contains filtered or unexported fields
}
DefaultEncoder struct
func NewDefaultEncoder ¶
func NewDefaultEncoder(mode *mode.Flag) *DefaultEncoder
NewDefaultEncoder creates a new default JSON encoder
func (*DefaultEncoder) Encode ¶
func (d *DefaultEncoder) Encode( w http.ResponseWriter, response gonethttpresponse.Response, ) (err error)
Encode encodes the body into JSON and writes it to the response
type DefaultStreamDecoder ¶
type DefaultStreamDecoder struct {
// contains filtered or unexported fields
}
DefaultStreamDecoder is the JSON decoder struct
func NewDefaultStreamDecoder ¶
func NewDefaultStreamDecoder( mode *goflagsmode.Flag, encoder Encoder, ) (*DefaultStreamDecoder, error)
NewDefaultStreamDecoder creates a new JSON decoder
func (*DefaultStreamDecoder) Decode ¶
func (d *DefaultStreamDecoder) Decode( w http.ResponseWriter, r *http.Request, dest interface{}, ) (err error)
Decode decodes the JSON request body and stores it in the destination
type DefaultStreamEncoder ¶
type DefaultStreamEncoder struct {
// contains filtered or unexported fields
}
DefaultStreamEncoder is the JSON encoder struct
func NewDefaultStreamEncoder ¶
func NewDefaultStreamEncoder(mode *goflagsmode.Flag) *DefaultStreamEncoder
NewDefaultStreamEncoder creates a new JSON encoder
func (*DefaultStreamEncoder) Encode ¶
func (d *DefaultStreamEncoder) Encode( w http.ResponseWriter, response gonethttpresponse.Response, ) (err error)
Encode encodes the body into JSON and writes it to the response
type Encoder ¶
type Encoder interface {
Encode(
w http.ResponseWriter,
response gonethttpresponse.Response,
) error
}
Encoder interface
Click to show internal directories.
Click to hide internal directories.