Documentation ¶
Index ¶
- func HandlerWithCodec(c Codec, h Handler) http.Handler
- func HandlerWithSelector(s CodecSelector, h Handler) http.Handler
- func NewRequestSelector(opts ...RequestSelectorOption) (*requestSelector, error)
- func Paginate(r *http.Request, opts ...PaginateOption) (count int, skip int, err error)
- func SetCodecURLKey(k string) func(r *requestSelector)
- type Codec
- type CodecSelector
- type Handler
- type HandlerFunc
- type PaginateOption
- type RequestSelectorOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandlerWithSelector ¶
func HandlerWithSelector(s CodecSelector, h Handler) http.Handler
func NewRequestSelector ¶
func NewRequestSelector(opts ...RequestSelectorOption) (*requestSelector, error)
func SetCodecURLKey ¶
func SetCodecURLKey(k string) func(r *requestSelector)
Types ¶
type Codec ¶
type Codec interface { // Encode and write the given data to the response writer with the requested status code // Will change the status code apropriately if there is an encoding error Respond(ctx context.Context, w http.ResponseWriter, code int, data interface{}) // Read will attempt to decode the body of a request onto the given data interface Read(ctx context.Context, r *http.Request, data interface{}) error }
type CodecSelector ¶
type Handler ¶
type Handler interface {
ServeCodec(c Codec, w http.ResponseWriter, r *http.Request)
}
type HandlerFunc ¶
type HandlerFunc func(c Codec, w http.ResponseWriter, r *http.Request)
func (*HandlerFunc) ServeCodec ¶
func (h *HandlerFunc) ServeCodec(c Codec, w http.ResponseWriter, r *http.Request)
type PaginateOption ¶
type PaginateOption func(*pagOpts) error
func DefaultCount ¶
func DefaultCount(n int) PaginateOption
func DefaultSkip ¶
func DefaultSkip(n int) PaginateOption
func MaxCount ¶
func MaxCount(n int) PaginateOption
func MaxSkip ¶
func MaxSkip(n int) PaginateOption
type RequestSelectorOption ¶
type RequestSelectorOption func(r *requestSelector)
func RegisterCodec ¶
func RegisterCodec(c Codec, values ...string) RequestSelectorOption
func SetDefaultCodec ¶
func SetDefaultCodec(c Codec) RequestSelectorOption
Click to show internal directories.
Click to hide internal directories.