Versions in this module Expand all Collapse all v0 v0.2.0 Sep 4, 2019 Changes in this version + var ErrForbidden = errors.New("Forbidden") + type Compiler interface + Compile func() error v0.1.0 Jan 3, 2017 Changes in this version + var DefaultConf = Conf + var ErrConflict = errors.New("Conflict") + var ErrNoStorage = errors.New("No Storage Defined") + var ErrNotFound = errors.New("Not Found") + var ErrNotImplemented = errors.New("Not Implemented") + var ErrUnauthorized = errors.New("Unauthorized") + var Logger = func(ctx context.Context, level LogLevel, msg string, fields map[string]interface{}) + var LoggerLevel = LogLevelInfo + var ReadOnly = []Mode + var ReadWrite = []Mode + var WriteOnly = []Mode + type ClearEventHandler interface + OnClear func(ctx context.Context, lookup *Lookup) error + type ClearEventHandlerFunc func(ctx context.Context, lookup *Lookup) error + func (e ClearEventHandlerFunc) OnClear(ctx context.Context, lookup *Lookup) error + type ClearedEventHandler interface + OnCleared func(ctx context.Context, lookup *Lookup, deleted *int, err *error) + type ClearedEventHandlerFunc func(ctx context.Context, lookup *Lookup, deleted *int, err *error) + func (e ClearedEventHandlerFunc) OnCleared(ctx context.Context, lookup *Lookup, deleted *int, err *error) + type Conf struct + AllowedModes []Mode + ForceTotal ForceTotalMode + PaginationDefaultLimit int + func (c Conf) IsModeAllowed(mode Mode) bool + type Counter interface + Count func(ctx context.Context, lookup *Lookup) (int, error) + type DeleteEventHandler interface + OnDelete func(ctx context.Context, item *Item) error + type DeleteEventHandlerFunc func(ctx context.Context, item *Item) error + func (e DeleteEventHandlerFunc) OnDelete(ctx context.Context, item *Item) error + type DeletedEventHandler interface + OnDeleted func(ctx context.Context, item *Item, err *error) + type DeletedEventHandlerFunc func(ctx context.Context, item *Item, err *error) + func (e DeletedEventHandlerFunc) OnDeleted(ctx context.Context, item *Item, err *error) + type Field struct + Alias string + Fields []Field + Name string + Params map[string]interface{} + type FindEventHandler interface + OnFind func(ctx context.Context, lookup *Lookup, offset, limit int) error + type FindEventHandlerFunc func(ctx context.Context, lookup *Lookup, offset, limit int) error + func (e FindEventHandlerFunc) OnFind(ctx context.Context, lookup *Lookup, offset, limit int) error + type ForceTotalMode int + const TotalAlways + const TotalDenied + const TotalOptIn + type FoundEventHandler interface + OnFound func(ctx context.Context, lookup *Lookup, list **ItemList, err *error) + type FoundEventHandlerFunc func(ctx context.Context, lookup *Lookup, list **ItemList, err *error) + func (e FoundEventHandlerFunc) OnFound(ctx context.Context, lookup *Lookup, list **ItemList, err *error) + type GetEventHandler interface + OnGet func(ctx context.Context, id interface{}) error + type GetEventHandlerFunc func(ctx context.Context, id interface{}) error + func (e GetEventHandlerFunc) OnGet(ctx context.Context, id interface{}) error + type GotEventHandler interface + OnGot func(ctx context.Context, item **Item, err *error) + type GotEventHandlerFunc func(ctx context.Context, item **Item, err *error) + func (e GotEventHandlerFunc) OnGot(ctx context.Context, item **Item, err *error) + type Index interface + Bind func(name string, s schema.Schema, h Storer, c Conf) *Resource + GetResource func(path string, parent *Resource) (*Resource, bool) + GetResources func() []*Resource + func NewIndex() Index + type InsertEventHandler interface + OnInsert func(ctx context.Context, items []*Item) error + type InsertEventHandlerFunc func(ctx context.Context, items []*Item) error + func (e InsertEventHandlerFunc) OnInsert(ctx context.Context, items []*Item) error + type InsertedEventHandler interface + OnInserted func(ctx context.Context, items []*Item, err *error) + type InsertedEventHandlerFunc func(ctx context.Context, items []*Item, err *error) + func (e InsertedEventHandlerFunc) OnInserted(ctx context.Context, items []*Item, err *error) + type Item struct + ETag string + ID interface{} + Payload map[string]interface{} + Updated time.Time + func NewItem(payload map[string]interface{}) (*Item, error) + func (i Item) GetField(name string) interface{} + type ItemList struct + Items []*Item + Limit int + Offset int + Total int + type LogLevel int + const LogLevelDebug + const LogLevelError + const LogLevelFatal + const LogLevelInfo + const LogLevelWarn + type Lookup struct + func NewLookup() *Lookup + func NewLookupWithQuery(q schema.Query) *Lookup + func (l *Lookup) AddFilter(filter string, v schema.Validator) error + func (l *Lookup) AddQuery(query schema.Query) + func (l *Lookup) ApplySelector(ctx context.Context, v schema.Validator, p map[string]interface{}, ...) (map[string]interface{}, error) + func (l *Lookup) Filter() schema.Query + func (l *Lookup) SetSelector(s string, v schema.Validator) error + func (l *Lookup) SetSort(sort string, v schema.Validator) error + func (l *Lookup) SetSorts(sorts []string) + func (l *Lookup) Sort() []string + type Mode int + const Clear + const Create + const Delete + const List + const Read + const Replace + const Update + type MultiGetter interface + MultiGet func(ctx context.Context, ids []interface{}) ([]*Item, error) + type ReferenceResolver func(path string) (*Resource, error) + type Resource struct + func (r *Resource) Alias(name string, v url.Values) + func (r *Resource) Bind(name, field string, s schema.Schema, h Storer, c Conf) *Resource + func (r *Resource) Clear(ctx context.Context, lookup *Lookup) (deleted int, err error) + func (r *Resource) Compile() error + func (r *Resource) Conf() Conf + func (r *Resource) Delete(ctx context.Context, item *Item) (err error) + func (r *Resource) Find(ctx context.Context, lookup *Lookup, offset, limit int) (list *ItemList, err error) + func (r *Resource) FindWithTotal(ctx context.Context, lookup *Lookup, offset, limit int) (list *ItemList, err error) + func (r *Resource) Get(ctx context.Context, id interface{}) (item *Item, err error) + func (r *Resource) GetAlias(name string) (url.Values, bool) + func (r *Resource) GetAliases() []string + func (r *Resource) GetResources() []*Resource + func (r *Resource) Insert(ctx context.Context, items []*Item) (err error) + func (r *Resource) MultiGet(ctx context.Context, ids []interface{}) (items []*Item, err error) + func (r *Resource) Name() string + func (r *Resource) ParentField() string + func (r *Resource) Path() string + func (r *Resource) Schema() schema.Schema + func (r *Resource) Update(ctx context.Context, item *Item, original *Item) (err error) + func (r *Resource) Use(e interface{}) error + func (r *Resource) Validator() schema.Validator + type Storer interface + Clear func(ctx context.Context, lookup *Lookup) (int, error) + Delete func(ctx context.Context, item *Item) error + Find func(ctx context.Context, lookup *Lookup, offset, limit int) (*ItemList, error) + Insert func(ctx context.Context, items []*Item) error + Update func(ctx context.Context, item *Item, original *Item) error + type UpdateEventHandler interface + OnUpdate func(ctx context.Context, item *Item, original *Item) error + type UpdateEventHandlerFunc func(ctx context.Context, item *Item, original *Item) error + func (e UpdateEventHandlerFunc) OnUpdate(ctx context.Context, item *Item, original *Item) error + type UpdatedEventHandler interface + OnUpdated func(ctx context.Context, item *Item, original *Item, err *error) + type UpdatedEventHandlerFunc func(ctx context.Context, item *Item, original *Item, err *error) + func (e UpdatedEventHandlerFunc) OnUpdated(ctx context.Context, item *Item, original *Item, err *error)