Documentation ¶
Index ¶
- Variables
- func SetDefault(c *Controller)
- type Controller
- func (c *Controller) DBErrorMapper() *aerrors.ErrorMapper
- func (c *Controller) GetModelStruct(model interface{}) (*models.ModelStruct, error)
- func (c *Controller) ModelSchemas() *models.ModelSchemas
- func (c *Controller) ModelStruct(model interface{}) (*mapping.ModelStruct, error)
- func (c *Controller) MustGetModelStruct(model interface{}) *models.ModelStruct
- func (c *Controller) Processor() scope.Processor
- func (c *Controller) RegisterModelRecursively(models ...interface{}) error
- func (c *Controller) RegisterModels(models ...interface{}) error
- func (c *Controller) RegisterSchemaModels(schemaName string, models ...interface{}) error
- func (c *Controller) SetLogger(logger unilogger.LeveledLogger)
- func (c *Controller) SetProcessor(p scope.Processor)
Constants ¶
This section is empty.
Variables ¶
var ( DefaultConfig *config.Controller = config.ReadDefaultControllerConfig() DefaultTestingConfig *config.Controller )
DefaultConfig is the controller default config used with the Default function
Functions ¶
Types ¶
type Controller ¶
type Controller struct { // Config is the configuration struct for the controller Config *config.Controller // Namer defines the function strategy how the model's and it's fields are being named NamerFunc namer.Namer // Flags defines the controller config flags Flags *flags.Container // StrictUnmarshalMode if set to true, the incoming data cannot contain // any unknown fields StrictUnmarshalMode bool // Validators // CreateValidator is used as a validator for the Create processes CreateValidator *validator.Validate //PatchValidator is used as a validator for the Patch processes PatchValidator *validator.Validate // contains filtered or unexported fields }
Controller is the data structure that is responsible for controlling all the models within single API
func Default ¶
func Default() *Controller
Default creates new *jsonapi.Controller with preset limits: Controller has also set the FlagUseLinks flag to true.
func DefaultTesting ¶
func DefaultTesting(t testing.TB, cfg *config.Controller) *Controller
DefaultTesting is the default controller used for testing
func New ¶
func New(cfg *config.Controller, logger unilogger.LeveledLogger) (*Controller, error)
New Creates raw *jsonapi.Controller with no limits and links.
func NewDefault ¶
func NewDefault() *Controller
NewDefault creates new default controller based on the default config
func (*Controller) DBErrorMapper ¶
func (c *Controller) DBErrorMapper() *aerrors.ErrorMapper
DBErrorMapper gets the database error manager
func (*Controller) GetModelStruct ¶
func (c *Controller) GetModelStruct(model interface{}) (*models.ModelStruct, error)
GetModelStruct returns the ModelStruct for provided model Returns error if provided model does not exists in the PrecomputedMap
func (*Controller) ModelSchemas ¶
func (c *Controller) ModelSchemas() *models.ModelSchemas
ModelSchemas returns model schemas for given controller
func (*Controller) ModelStruct ¶
func (c *Controller) ModelStruct(model interface{}) (*mapping.ModelStruct, error)
ModelStruct gets the model struct mapping. Implements repository.ModelStructer
func (*Controller) MustGetModelStruct ¶
func (c *Controller) MustGetModelStruct(model interface{}) *models.ModelStruct
MustGetModelStruct gets (concurrently safe) the model struct from the cached model Map panics if the model does not exists in the map.
func (*Controller) Processor ¶
func (c *Controller) Processor() scope.Processor
Processor returns the query processor for the controller
func (*Controller) RegisterModelRecursively ¶
func (c *Controller) RegisterModelRecursively(models ...interface{}) error
RegisterModelRecursively registers provided models and it's realtionship fields recursively
func (*Controller) RegisterModels ¶
func (c *Controller) RegisterModels(models ...interface{}) error
RegisterModels precomputes provided models, making it easy to check models relationships and attributes.
func (*Controller) RegisterSchemaModels ¶
func (c *Controller) RegisterSchemaModels(schemaName string, models ...interface{}) error
RegisterSchemaModels registers the model for the provided schema
func (*Controller) SetLogger ¶
func (c *Controller) SetLogger(logger unilogger.LeveledLogger)
SetLogger sets the logger for the controller operations
func (*Controller) SetProcessor ¶
func (c *Controller) SetProcessor(p scope.Processor)
SetProcessor sets the query processor for the controller