Documentation ¶
Index ¶
- func NewMemoryStore() *crud.MemoryStore[NewEvent, Event, FindFilters]
- func Router(storer Storer, authService auth.Service) func(chi.Router)
- func URLFromID(baseURL string, id string) (string, error)
- type Authorizer
- func (a *Authorizer) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)
- func (a *Authorizer) Delete(ctx context.Context, id string) error
- func (a *Authorizer) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
- func (a *Authorizer) FindByID(ctx context.Context, id string) (*Event, error)
- func (a *Authorizer) Update(ctx context.Context, event *Event) (*Event, error)
- type CreateOperation
- type DeleteOperation
- type Event
- type FindFilters
- type FindResponse
- type Involved
- type NewEvent
- type Operator
- func (i *Operator) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)
- func (i *Operator) Delete(ctx context.Context, id string) error
- func (i *Operator) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
- func (i *Operator) FindByID(ctx context.Context, id string) (*Event, error)
- func (i *Operator) Update(ctx context.Context, event *Event) (*Event, error)
- type Service
- func (s *Service) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)
- func (s *Service) Delete(ctx context.Context, id string) error
- func (s *Service) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
- func (s *Service) FindByID(ctx context.Context, id string) (*Event, error)
- func (s *Service) Update(ctx context.Context, event *Event) (*Event, error)
- type SqlStore
- func (s *SqlStore) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)
- func (s *SqlStore) Delete(ctx context.Context, id string) error
- func (s *SqlStore) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
- func (s *SqlStore) FindByID(ctx context.Context, id string) (*Event, error)
- func (s *SqlStore) Update(ctx context.Context, event *Event) (*Event, error)
- type Storer
- type UpdateOperation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMemoryStore ¶
func NewMemoryStore() *crud.MemoryStore[NewEvent, Event, FindFilters]
NewMemoryStore returns a new in memory store.
Types ¶
type Authorizer ¶
type Authorizer struct {
// contains filtered or unexported fields
}
Authorizer wraps a Storer. It checks the authorization before propagating the call to the wrapped storer.
func (*Authorizer) Delete ¶
func (a *Authorizer) Delete(ctx context.Context, id string) error
Delete can be called by an admin user or the event author.
func (*Authorizer) Find ¶
func (a *Authorizer) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
Find can be called by everyone.
type CreateOperation ¶
type CreateOperation struct { Event *Event // contains filtered or unexported fields }
func NewCreateOperation ¶
func NewCreateOperation(event *Event, userID string) CreateOperation
func (CreateOperation) UserID ¶
func (o CreateOperation) UserID() string
type DeleteOperation ¶
type DeleteOperation struct { ID string // contains filtered or unexported fields }
func NewDeleteOperation ¶
func NewDeleteOperation(id string, userID string) DeleteOperation
func (DeleteOperation) UserID ¶
func (o DeleteOperation) UserID() string
type Event ¶
type Event struct { ID string `json:"id" db:"id"` Deactivated bool `json:"deactivated" db:"deactivated"` Published bool `json:"published" db:"published"` Canceled bool `json:"canceled" db:"canceled"` Parent string `json:"parent" db:"parent"` ParentListed bool `json:"parentListed" db:"parentListed"` Name string `json:"name" db:"name"` Organizers []string `json:"organizers" db:"organizers"` Involved []Involved `json:"involved" db:"involved"` Location string `json:"location" db:"location"` Location2 string `json:"location2" db:"location2"` Description string `json:"description" db:"description"` Start time.Time `json:"start" db:"start"` End *time.Time `json:"end" db:"end"` Tags []string `json:"tags" db:"tags"` Image string `json:"image" db:"image"` OwnedBy []string `json:"ownedBy" db:"ownedBy"` }
Event defines a calendar event. It implements indexo.Coppyable.
func EventFromNewEvent ¶
func (Event) Identifier ¶
func (*Event) Indexable ¶
Indexable indicates wether the event should be indexed in the search. All events are indexable if they are not deactivated.
type FindFilters ¶
type FindFilters struct { ID *string `json:"id,omitempty"` Deactivated *bool `json:"deactivated,omitempty"` Published *bool `json:"published,omitempty"` Canceled *bool `json:"canceled,omitempty"` Parent *string `json:"parent,omitempty"` Name *string `json:"name,omitempty"` LikeName *string `json:"likeName,omitempty"` Organizers []string `json:"organizers,omitempty"` Location *string `json:"location,omitempty"` Location2 *string `json:"location2,omitempty"` Description *string `json:"description,omitempty"` Start *time.Time `json:"start,omitempty"` StartBefore *time.Time `json:"startBefore,omitempty"` StartAfter *time.Time `json:"startAfter,omitempty"` End *time.Time `json:"end,omitempty"` EndBefore *time.Time `json:"endBefore,omitempty"` EndAfter *time.Time `json:"endAfter,omitempty"` Tags []string `json:"tags,omitempty"` OwnedBy []string `json:"ownedBy,omitempty"` OwnedByOrOrganizers []string }
FindFilters defines the possible filters for the find method.
type FindResponse ¶
type FindResponse[Model any] struct { // in:body Model *Model }
type Involved ¶
type Involved struct { Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` }
Involved defines an entity, that is involved with an event.
type NewEvent ¶
type NewEvent struct { Published bool `json:"published"` Parent string `json:"parent"` ParentListed bool `json:"parentListed"` Name string `json:"name"` Organizers []string `json:"organizers"` Involved []Involved `json:"involved"` Location string `json:"location"` Location2 string `json:"location2"` Description string `json:"description"` Start time.Time `json:"start"` End *time.Time `json:"end"` Tags []string `json:"tags"` Image string `json:"image"` OwnedBy []string `json:"ownedBy"` }
NewEvent defines the data for a new event.
type Operator ¶
type Operator struct {
// contains filtered or unexported fields
}
func (*Operator) Find ¶
func (i *Operator) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
NewService returns a new event service.
func (*Service) Find ¶
func (s *Service) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
type SqlStore ¶
type SqlStore struct {
// contains filtered or unexported fields
}
func NewSqlStore ¶
NewSqlStore returns a new sql db event store.
func (*SqlStore) Find ¶
func (s *SqlStore) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)
type Storer ¶
type Storer = crud.Storer[NewEvent, Event, FindFilters]
Storer defines a service for CRUD operations on the event model.
func NewAuthorizer ¶
NewAuthorizer returns a new authorizer limiting access to the provided store.
type UpdateOperation ¶
type UpdateOperation struct { Event *Event // contains filtered or unexported fields }
func NewUpdateOperation ¶
func NewUpdateOperation(event *Event, userID string) UpdateOperation
func (UpdateOperation) UserID ¶
func (o UpdateOperation) UserID() string