controller

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

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

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 Default

func Default() *Controller

Default returns current default controller.

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.

Jump to

Keyboard shortcuts

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