Documentation
¶
Overview ¶
Package controller contains root neuron structure. It is responsible for getting access to registered models and their repositories. It contains the configuration, validators and default query processor.
Index ¶
- func SetDefault(c *Controller)
- type Controller
- func (c *Controller) Close() error
- func (c *Controller) GetRepository(model interface{}) (repository.Repository, error)
- func (c *Controller) ListModels() []*mapping.ModelStruct
- func (c *Controller) ModelStruct(model interface{}) (*mapping.ModelStruct, error)
- func (c *Controller) RegisterModels(models ...interface{}) error
- func (c *Controller) RegisterRepository(name string, cfg *config.Repository) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefault ¶
func SetDefault(c *Controller)
SetDefault sets given Controller 'c' as the default.
Types ¶
type Controller ¶
type Controller controller.Controller
Controller is the structure that controls whole jsonapi behavior. It contains repositories, model definitions, query builders and it's own config.
var DefaultController *Controller
DefaultController is the Default controller used if no 'controller' is provided for operations
func MustGetNew ¶
func MustGetNew(cfg *config.Controller) *Controller
MustGetNew creates new controller for given provided 'cfg' config. Panics on error.
func New ¶
func New(cfg *config.Controller) (*Controller, error)
New creates new controller for given config 'cfg'.
func NewDefault ¶
func NewDefault() *Controller
NewDefault creates and returns new default Controller.
func (*Controller) Close ¶ added in v0.2.1
func (c *Controller) Close() error
Close closes all repository instances.
func (*Controller) GetRepository ¶ added in v0.2.1
func (c *Controller) GetRepository(model interface{}) (repository.Repository, error)
GetRepository gets the repository for the provided model.
func (*Controller) ListModels ¶ added in v0.5.1
func (c *Controller) ListModels() []*mapping.ModelStruct
ListModels returns a list of registered models for given controller.
func (*Controller) ModelStruct ¶
func (c *Controller) ModelStruct(model interface{}) (*mapping.ModelStruct, error)
ModelStruct gets the model struct on the base of the provided model
func (*Controller) RegisterModels ¶
func (c *Controller) RegisterModels(models ...interface{}) error
RegisterModels registers provided models within the context of the provided Controller
func (*Controller) RegisterRepository ¶ added in v0.2.1
func (c *Controller) RegisterRepository(name string, cfg *config.Repository) error
RegisterRepository registers provided repository for given 'name' and with with given 'cfg' config.