resources

package
v0.0.0-...-f3ad2b4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: MIT Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminResource

type AdminResource struct{}

AdminResource is a mixin that restricts create, update and delete. Only users with the role admin or with the permission action_collectionname may create, update or delete objects. So if you want to allow a role to update all items in a collection "totos", the permission update_todos to the role.

func (AdminResource) AllowCreate

func (AdminResource) AllowCreate(res kit.Resource, obj kit.Model, user kit.User) bool

func (AdminResource) AllowDelete

func (AdminResource) AllowDelete(res kit.Resource, obj kit.Model, user kit.User) bool

func (AdminResource) AllowUpdate

func (AdminResource) AllowUpdate(res kit.Resource, obj kit.Model, old kit.Model, user kit.User) bool

type AfterCreateHook

type AfterCreateHook interface {
	AfterCreate(res kit.Resource, obj kit.Model, user kit.User) apperror.Error
}

type AfterDeleteHook

type AfterDeleteHook interface {
	AfterDelete(res kit.Resource, obj kit.Model, user kit.User) apperror.Error
}

type AfterUpdateHook

type AfterUpdateHook interface {
	AfterUpdate(res kit.Resource, obj, oldobj kit.Model, user kit.User) apperror.Error
}

type AllowCreateHook

type AllowCreateHook interface {
	AllowCreate(res kit.Resource, obj kit.Model, user kit.User) bool
}

type AllowDeleteHook

type AllowDeleteHook interface {
	AllowDelete(res kit.Resource, obj kit.Model, user kit.User) bool
}

type AllowFindHook

type AllowFindHook interface {
	AllowFind(res kit.Resource, model kit.Model, user kit.User) bool
}

type AllowUpdateHook

type AllowUpdateHook interface {
	AllowUpdate(res kit.Resource, obj kit.Model, old kit.Model, user kit.User) bool
}

type ApiAfterFindHook

type ApiAfterFindHook interface {
	ApiAfterFind(res kit.Resource, objects []kit.Model, req kit.Request, resp kit.Response) apperror.Error
}

type ApiAlterQueryHook

type ApiAlterQueryHook interface {
	// Alter an API query before it is executed.
	ApiAlterQuery(res kit.Resource, query *db.Query, r kit.Request) apperror.Error
}

type ApiCreateHook

type ApiCreateHook interface {
	ApiCreate(res kit.Resource, obj kit.Model, r kit.Request) kit.Response
}

type ApiDeleteHook

type ApiDeleteHook interface {
	ApiDelete(res kit.Resource, id string, r kit.Request) kit.Response
}

type ApiFindHook

type ApiFindHook interface {
	ApiFind(res kit.Resource, query *db.Query, r kit.Request) kit.Response
}

type ApiFindOneHook

type ApiFindOneHook interface {
	ApiFindOne(res kit.Resource, rawId string, r kit.Request) kit.Response
}

type ApiHttpRoutes

type ApiHttpRoutes interface {
	// Allows to set up custom http handlers with the httprouter directly.
	HttpRoutes(kit.Resource) []kit.HttpRoute
}

ApiHttpRoutes allows a reseource to specify custom http routes.

type ApiUpdateHook

type ApiUpdateHook interface {
	ApiUpdate(res kit.Resource, obj kit.Model, r kit.Request) kit.Response
}

type BeforeCreateHook

type BeforeCreateHook interface {
	BeforeCreate(res kit.Resource, obj kit.Model, user kit.User) apperror.Error
}

type BeforeDeleteHook

type BeforeDeleteHook interface {
	BeforeDelete(res kit.Resource, obj kit.Model, user kit.User) apperror.Error
}

type BeforeUpdateHook

type BeforeUpdateHook interface {
	BeforeUpdate(res kit.Resource, obj, oldobj kit.Model, user kit.User) apperror.Error
}

type CreateHook

type CreateHook interface {
	Create(res kit.Resource, obj kit.Model, user kit.User) apperror.Error
}

type DeleteHook

type DeleteHook interface {
	Delete(res kit.Resource, obj kit.Model, user kit.User) apperror.Error
}

type LoggedInResource

type LoggedInResource struct{}

LoggedInResource is a resource mixin that restricts create, read and update operations to logged in users.

func (LoggedInResource) AllowCreate

func (LoggedInResource) AllowCreate(res kit.Resource, obj kit.Model, user kit.User) bool

func (LoggedInResource) AllowDelete

func (LoggedInResource) AllowDelete(res kit.Resource, obj kit.Model, user kit.User) bool

func (LoggedInResource) AllowUpdate

func (LoggedInResource) AllowUpdate(res kit.Resource, obj kit.Model, old kit.Model, user kit.User) bool

type MethodsHook

type MethodsHook interface {
	Methods(kit.Resource) []kit.Method
}

MethodsHook allows a resource to specify additional methods.

type PublicWriteResource

type PublicWriteResource struct{}

PublicWriteResource is a resource mixin that allows create/update/delete to all API users, event without an account.

func (PublicWriteResource) AllowCreate

func (PublicWriteResource) AllowCreate(res kit.Resource, obj kit.Model, user kit.User) bool

func (PublicWriteResource) AllowDelete

func (PublicWriteResource) AllowDelete(res kit.Resource, obj kit.Model, user kit.User) bool

func (PublicWriteResource) AllowUpdate

func (PublicWriteResource) AllowUpdate(res kit.Resource, obj kit.Model, old kit.Model, user kit.User) bool

type ReadOnlyResource

type ReadOnlyResource struct{}

ReadOnlyResource is a resource mixin that prevents all create/update/delete actions via the API.

func (ReadOnlyResource) AllowCreate

func (r ReadOnlyResource) AllowCreate(res kit.Resource, obj kit.Model, user kit.User) bool

func (ReadOnlyResource) AllowDelete

func (r ReadOnlyResource) AllowDelete(res kit.Resource, obj kit.Model, user kit.User) bool

func (ReadOnlyResource) AllowUpdate

func (r ReadOnlyResource) AllowUpdate(res kit.Resource, obj kit.Model, user kit.User) bool

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

func NewResource

func NewResource(model kit.Model, hooks interface{}, isPublic bool) *Resource

func (*Resource) ApiCreate

func (res *Resource) ApiCreate(obj kit.Model, r kit.Request) kit.Response

func (*Resource) ApiDelete

func (res *Resource) ApiDelete(id string, r kit.Request) kit.Response

func (*Resource) ApiFind

func (res *Resource) ApiFind(query *db.Query, r kit.Request) kit.Response

func (*Resource) ApiFindOne

func (res *Resource) ApiFindOne(rawId string, r kit.Request) kit.Response

func (*Resource) ApiPartialUpdate

func (res *Resource) ApiPartialUpdate(obj kit.Model, r kit.Request) kit.Response

func (*Resource) ApiUpdate

func (res *Resource) ApiUpdate(obj kit.Model, r kit.Request) kit.Response

func (*Resource) Backend

func (res *Resource) Backend() db.Backend

func (*Resource) Collection

func (res *Resource) Collection() string

func (Resource) Count

func (res Resource) Count(q *db.Query) (int, apperror.Error)

func (*Resource) Create

func (res *Resource) Create(obj kit.Model, user kit.User) apperror.Error

func (*Resource) CreateModel

func (res *Resource) CreateModel() kit.Model

func (*Resource) Debug

func (res *Resource) Debug() bool

func (*Resource) Delete

func (res *Resource) Delete(obj kit.Model, user kit.User) apperror.Error

func (*Resource) FindOne

func (res *Resource) FindOne(rawId interface{}) (kit.Model, apperror.Error)

func (*Resource) Hooks

func (res *Resource) Hooks() interface{}

func (*Resource) IsPublic

func (res *Resource) IsPublic() bool

func (*Resource) Model

func (res *Resource) Model() kit.Model

func (*Resource) ModelInfo

func (res *Resource) ModelInfo() *db.ModelInfo

func (*Resource) PartialUpdate

func (res *Resource) PartialUpdate(obj kit.Model, user kit.User) apperror.Error

func (Resource) Q

func (res Resource) Q() *db.Query

*

  • Return a new query initialized with the backend.

func (Resource) Query

func (res Resource) Query(q *db.Query, targetSlice ...interface{}) ([]kit.Model, apperror.Error)

*

  • Perform a query.

func (*Resource) Registry

func (res *Resource) Registry() kit.Registry

func (*Resource) SetBackend

func (res *Resource) SetBackend(b db.Backend)

func (*Resource) SetDebug

func (res *Resource) SetDebug(x bool)

func (*Resource) SetHooks

func (res *Resource) SetHooks(h interface{})

func (*Resource) SetModel

func (res *Resource) SetModel(x kit.Model)

func (*Resource) SetRegistry

func (res *Resource) SetRegistry(x kit.Registry)

func (*Resource) Update

func (res *Resource) Update(obj kit.Model, user kit.User) apperror.Error

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(debug bool, registry kit.Registry) *Service

func (*Service) Create

func (s *Service) Create(m kit.Model, user kit.User) apperror.Error

func (*Service) Debug

func (s *Service) Debug() bool

func (*Service) Delete

func (s *Service) Delete(m kit.Model, user kit.User) apperror.Error

func (*Service) FindOne

func (s *Service) FindOne(modelType string, id string) (kit.Model, apperror.Error)

func (*Service) Q

func (s *Service) Q(modelType string) (*db.Query, apperror.Error)

func (*Service) RegisterResource

func (s *Service) RegisterResource(res kit.Resource)

func (*Service) Registry

func (s *Service) Registry() kit.Registry

func (*Service) Resource

func (s *Service) Resource(name string) kit.Resource

func (*Service) SetDebug

func (s *Service) SetDebug(x bool)

func (*Service) SetDefaultBackend

func (s *Service) SetDefaultBackend(b db.Backend)

func (*Service) SetRegistry

func (s *Service) SetRegistry(x kit.Registry)

func (*Service) Update

func (s *Service) Update(m kit.Model, user kit.User) apperror.Error

type UpdateHook

type UpdateHook interface {
	Update(res kit.Resource, obj kit.Model, user kit.User) apperror.Error
}

type UserResource

type UserResource struct{}

UserResource is a resource mixin that restricts create, read and update operations to admins, users with the permission action_collectionname (see AdminResource) or users that own the model. This can only be used for models that implement the appkit.UserModel interface.

func (UserResource) AllowCreate

func (UserResource) AllowCreate(res kit.Resource, obj kit.Model, user kit.User) bool

func (UserResource) AllowDelete

func (UserResource) AllowDelete(res kit.Resource, obj kit.Model, user kit.User) bool

func (UserResource) AllowFind

func (UserResource) AllowFind(res kit.Resource, model kit.Model, user kit.User) bool

func (UserResource) AllowUpdate

func (UserResource) AllowUpdate(res kit.Resource, obj kit.Model, old kit.Model, user kit.User) bool

Jump to

Keyboard shortcuts

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