Documentation ¶
Index ¶
- Variables
- func DefaultSetError(ctx context.Context, req *http.Request, w http.ResponseWriter, err error)
- func MarshalerForRequest(r *http.Request) (Marshaler, Marshaler)
- func OverrideMarshaler(contentType string, m Marshaler)
- func OverrideParametrizedMarshaler(contentType string, f func(ContentTypeOptions) Marshaler)
- type ContentTypeOptions
- type Marshaler
- type MarshalerPbJSON
Constants ¶
This section is empty.
Variables ¶
var SetError func(context.Context, *http.Request, http.ResponseWriter, error) = DefaultSetError
SetError is used to output errors to the client. You can override that in the runtime.
var TransformUnmarshalerError = func(err error) error { return err }
TransformUnmarshalerError is called for every error reported by unmarshaler. It can be used to transform the error returned to the client (embed HTTP code in it, mask text, etc.).
Functions ¶
func DefaultSetError ¶
DefaultSetError is the default error output.
func MarshalerForRequest ¶
MarshalerForRequest returns marshalers for inbound and outbound bodies.
func OverrideMarshaler ¶
OverrideMarshaler replaces Marshaler for given content-type.
func OverrideParametrizedMarshaler ¶
func OverrideParametrizedMarshaler(contentType string, f func(ContentTypeOptions) Marshaler)
OverrideParametrizedMarshaler replaces MarshalGetter for given content-type. Use it if your marshaler needs ContentTypeOptions to successfully unmarshal the request.
Types ¶
type ContentTypeOptions ¶
ContentTypeOptions are MIME annotations provided with Content-Type or Accept headers.
type Marshaler ¶
type Marshaler interface { ContentType() string Unmarshal(io.Reader, interface{}) error Marshal(io.Writer, interface{}) error }
Marshaler is a processor that can marshal and unmarshal data to some content-type.
func DefaultMarshaler ¶
DefaultMarshaler returns a default marshaler for the platform.
type MarshalerPbJSON ¶
type MarshalerPbJSON struct { Marshaler *runtime.JSONPb Unmarshaler *runtime.JSONPb GogoMarshaler *gogojsonpb.Marshaler GogoUnmarshaler *gogojsonpb.Unmarshaler }
MarshalerPbJSON (un)marshals between JSON and proto.Messages. It supports both golang/pb and gogo/pb.
func (MarshalerPbJSON) ContentType ¶
func (MarshalerPbJSON) ContentType() string