httpruntime

package
v2.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

SetError is used to output errors to the client. You can override that in the runtime.

View Source
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

func DefaultSetError(ctx context.Context, req *http.Request, w http.ResponseWriter, err error)

DefaultSetError is the default error output.

func MarshalerForRequest

func MarshalerForRequest(r *http.Request) (Marshaler, Marshaler)

MarshalerForRequest returns marshalers for inbound and outbound bodies.

func OverrideMarshaler

func OverrideMarshaler(contentType string, m Marshaler)

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

type ContentTypeOptions map[string]string

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

func DefaultMarshaler(params map[string]string) Marshaler

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

func (MarshalerPbJSON) Marshal

func (m MarshalerPbJSON) Marshal(w io.Writer, src interface{}) error

func (MarshalerPbJSON) Unmarshal

func (m MarshalerPbJSON) Unmarshal(r io.Reader, dst interface{}) error

Directories

Path Synopsis
Package httpmw provides middlewares that are automatically used by the generated code.
Package httpmw provides middlewares that are automatically used by the generated code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL