Documentation
¶
Index ¶
- func AnonymousHandler(handler rest.HandlerFunc) func(*rest.Request, rest.Responder)
- func JsonDecoder(reader io.Reader, v interface{}, trace retrace.Tracer) error
- type BindingFunc
- type ContentTypeDecoder
- type ContentTypeDecoders
- type ContentTypeEncoder
- type ContentTypeEncoders
- type RootHandler
- type SimpleRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnonymousHandler ¶
Types ¶
type BindingFunc ¶
type ContentTypeDecoder ¶
type ContentTypeDecoders ¶
type ContentTypeDecoders struct {
// contains filtered or unexported fields
}
func NewContentTypeDecoders ¶
func NewContentTypeDecoders() *ContentTypeDecoders
func (*ContentTypeDecoders) DecodeBody ¶
func (*ContentTypeDecoders) Get ¶
func (cd *ContentTypeDecoders) Get(types []string) *ContentTypeDecoder
func (*ContentTypeDecoders) Set ¶
func (cd *ContentTypeDecoders) Set(decoder *ContentTypeDecoder)
type ContentTypeEncoder ¶
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))
}
Click to show internal directories.
Click to hide internal directories.