Documentation
¶
Index ¶
- func GorillaParams(next http.Handler) http.Handler
- func Modules(f func(alias string, module Module) bool)
- func Register(alias string, module Module)
- type BaseModule
- type Controller
- type Handler
- type Methods
- type Module
- type Params
- type PluralDeleter
- type PluralGetter
- type PluralPatcher
- type PluralPoster
- type PluralPutter
- type SingleDeleter
- type SingleGetter
- type SinglePatcher
- type SinglePoster
- type SinglePutter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GorillaParams ¶
GorillaParams extracts URI params from the request (when using gorolla/mux).
Types ¶
type BaseModule ¶
BaseModule contains a basic set of logic and provides basic operations on resources (like "Register", "Unregister" etc).
func NewBaseModule ¶
func NewBaseModule() *BaseModule
NewBaseModule is a constructor func for BaseModule.
func (*BaseModule) Controllers ¶
func (m *BaseModule) Controllers(f func(string, Controller) bool)
Controllers calls the provided func sequentially for each available resource. If func returns false the "for" loop will be stopped.
func (*BaseModule) Register ¶
func (m *BaseModule) Register(name string, resource Controller) error
Register makes resource available by provided alias.
func (*BaseModule) Unregister ¶
func (m *BaseModule) Unregister(name string) error
Unregister removes resource from the list by alias.
type Controller ¶
type Controller interface {
mw.Controller
Init() error
}
Controller interface is a bare minimal controller.
type Handler ¶
type Handler interface {
http.Handler
Use(string, Module) error
Map(interface{}) inject.TypeMapper
}
Handler interface describes HTTP API handler.
type Methods ¶
type Methods []string
Methods is a collection of HTTP methods.
type Module ¶
type Module interface {
// Register should add Controller to module resources.
Register(alias string, controller Controller) error
// Unregister should remove the Controller from module resources.
Unregister(alias string) error
// Controllers should call the provided func sequentially for each available
// resource. If func returns false the "for" loop should be interrupted.
Controllers(func(alias string, controller Controller) bool)
}
Module represents single module with lite API (it means that all its routes can be generated only once at startup).
type Params ¶
Params is a key/value map containing the request parameters from the URI.
func ParamsFromContext ¶
ParamsFromContext pulls the URL parameters from a request context, or returns nil if none are present.
type PluralDeleter ¶
type PluralDeleter interface {
Controller
DeleteAll(ctx context.Context, params url.Values) (interface{}, error)
}
PluralDeleter should be able to delete a list of models.
type PluralGetter ¶
type PluralGetter interface {
Controller
GetAll(ctx context.Context, params url.Values) (interface{}, error)
}
PluralGetter should be able to provide a list of available models.
type PluralPatcher ¶
type PluralPatcher interface {
Controller
PatchAll(ctx context.Context, params url.Values, f func(v interface{}) error) (interface{}, error)
}
PluralPatcher should be able to patch a list of models.
type PluralPoster ¶
type PluralPoster interface {
Controller
PostAll(ctx context.Context, f func(v interface{}) error) (interface{}, error)
}
PluralPoster should be able to store a list of model to the storage.
type PluralPutter ¶
type PluralPutter interface {
Controller
PutAll(ctx context.Context, params url.Values, f func(v interface{}) error) (interface{}, error)
}
PluralPutter should be able to update a list of models.
type SingleDeleter ¶
type SingleDeleter interface {
Controller
Delete(ctx context.Context, pk string) (interface{}, error)
}
SingleDeleter should be able to delete a single model by primary key(s).
type SingleGetter ¶
type SingleGetter interface {
Controller
Get(ctx context.Context, pk string) (interface{}, error)
}
SingleGetter should be able to provide a single model by primary key(s)
type SinglePatcher ¶
type SinglePatcher interface {
Controller
Patch(ctx context.Context, pk string, f func(v interface{}) error) (interface{}, error)
}
SinglePatcher should be able to patch a single model by primary key(s).
type SinglePoster ¶
type SinglePoster interface {
Controller
Post(ctx context.Context, f func(v interface{}) error) (interface{}, error)
}
SinglePoster should be able to store a single model to the storage.
type SinglePutter ¶
type SinglePutter interface {
Controller
Put(ctx context.Context, pk string, f func(v interface{}) error) (interface{}, error)
}
SinglePutter should be able to update a single model by primary key(s).