handling

package
v0.0.0-...-339e9c5 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2015 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnonymousHandler

func AnonymousHandler(handler rest.HandlerFunc) func(*rest.Request, rest.Responder)

func JsonDecoder

func JsonDecoder(reader io.Reader, v interface{}, trace retrace.Tracer) error

Types

type BindingFunc

type BindingFunc func(rest.HandlerFunc) func(*rest.Request, rest.Responder)

type ContentTypeDecoder

type ContentTypeDecoder struct {
	ContentType string
	Decode      func(r io.Reader, v interface{}, trace retrace.Tracer) error
}

type ContentTypeDecoders

type ContentTypeDecoders struct {
	// contains filtered or unexported fields
}

func NewContentTypeDecoders

func NewContentTypeDecoders() *ContentTypeDecoders

func (*ContentTypeDecoders) DecodeBody

func (cd *ContentTypeDecoders) DecodeBody(req *rest.Request, trace retrace.Tracer) error

func (*ContentTypeDecoders) Get

func (cd *ContentTypeDecoders) Get(types []string) *ContentTypeDecoder

func (*ContentTypeDecoders) Set

func (cd *ContentTypeDecoders) Set(decoder *ContentTypeDecoder)

type ContentTypeEncoder

type ContentTypeEncoder struct {
	ContentType string
	Encode      func(v interface{}) ([]byte, error)
}

type ContentTypeEncoders

type ContentTypeEncoders struct {
	// contains filtered or unexported fields
}

func NewContentTypeEncoders

func NewContentTypeEncoders() *ContentTypeEncoders

func (*ContentTypeEncoders) Encode

func (cte *ContentTypeEncoders) Encode(data interface{}, contentType string) ([]byte, error)

func (*ContentTypeEncoders) Set

func (cte *ContentTypeEncoders) Set(encoder *ContentTypeEncoder)

type RootHandler

type RootHandler struct {
	Binder       BindingFunc
	TraceHeader  string
	SpanHeader   string
	Encoders     *ContentTypeEncoders
	Decoders     *ContentTypeDecoders
	TraceHandler func(*retrace.TraceMessage)
}

RootHandler binds api endpoint to a router

Example:

	func newSetupHandlers(router *mux.Router, graph inject.Graph) {
		//Set Custom Binder
		kandle := new(KraveHandler)
		root := &RootHandler{
			Binder: kandle.RequiresDeviceAuthentication,
		}

		//Bind
		pingEndpoint := new(PingEndpoint)
		pingHandler := new(PingHandler)
		root.Bind(router, pingEndpoint, pingHandler)
	}

func NewRootHandler

func NewRootHandler() *RootHandler

func (*RootHandler) Bind

func (root *RootHandler) Bind(router SimpleRouter, endpoint rest.ServerResource, handler rest.Handler, resourceRoot string)

func (*RootHandler) BindAll

func (root *RootHandler) BindAll(router SimpleRouter, endpoints map[rest.ServerResource]rest.Handler, resourceRoot string)

BindAll is a helper for calling Bind on a list of endpoints

type SimpleRouter

type SimpleRouter interface {
	RegisterRoute(verb, path string, f func(http.ResponseWriter, *http.Request))
}

Jump to

Keyboard shortcuts

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