Documentation ¶
Index ¶
- Constants
- func CurrentFilter(notif Notification) bool
- func ExpiredFilter(notif Notification) bool
- type Cleaner
- type Controller
- type Notification
- type Repository
- func (r *Repository) CreateOne(notification Notification) bool
- func (r *Repository) DeleteAll(uuids []apimongo.UUID) (bool, error)
- func (r *Repository) DeleteOne(uuid apimongo.UUID) (bool, error)
- func (r *Repository) GetAll() ([]Notification, error)
- func (r *Repository) GetOne(uuid apimongo.UUID) (*Notification, error)
Constants ¶
const ( // GetPath path for HTTP GET Method which to query for array of notifications GetPath = "/notifications" // SingleGetPath path for HTTP GET Method to query for single notification SingleGetPath = GetPath + "/" + uuidPattern // CreatePath path for HTTP POST Method which creates new notification CreatePath = "/notifications" // DeletePath path for HTTP DELETE Method which deletes notification DeletePath = "/notifications/" + uuidPattern )
Variables ¶
This section is empty.
Functions ¶
func CurrentFilter ¶
func CurrentFilter(notif Notification) bool
CurrentFilter returns true if notification is current
func ExpiredFilter ¶
func ExpiredFilter(notif Notification) bool
ExpiredFilter returns true if notification is expired
Types ¶
type Cleaner ¶
type Cleaner struct {
Repository *Repository
}
Cleaner handles all work related to cleaning repository.
func (*Cleaner) StartPeriodicCleaner ¶
func (c *Cleaner) StartPeriodicCleaner()
StartPeriodicCleaner starts periodic task to cleanup
type Controller ¶
type Controller struct {
Repository *Repository
}
Controller handles all notification related requests.
func (*Controller) Create ¶
func (c *Controller) Create(w http.ResponseWriter, r *http.Request)
Create creates a new notification.
func (*Controller) Delete ¶
func (c *Controller) Delete(w http.ResponseWriter, r *http.Request)
Delete deletes notification.
func (*Controller) Get ¶
func (c *Controller) Get(w http.ResponseWriter, r *http.Request)
Get returns one notification.
func (*Controller) GetAll ¶
func (c *Controller) GetAll(w http.ResponseWriter, r *http.Request)
GetAll returns all notifications.
type Notification ¶
type Notification struct { ID mongo.UUID `json:"_id" bson:"_id"` Title *string `json:"title" bson:"title"` Message *string `json:"message,omitempty" bson:"message,omitempty"` StartTime *mongo.Timestamp `json:"start_time" bson:"start_time"` EndTime *mongo.Timestamp `json:"end_time" bson:"end_time"` Source *string `json:"source,omitempty" bson:"source,omitempty"` }
Notification model for storing notifications
func FilterNotificatons ¶
func FilterNotificatons(notifications []Notification, filterFunc func(Notification) bool) []Notification
FilterNotificatons filters notification using provided filter func
type Repository ¶
Repository accesses notifications store
func (*Repository) CreateOne ¶
func (r *Repository) CreateOne(notification Notification) bool
CreateOne creates new notification for specified params
func (*Repository) DeleteAll ¶
func (r *Repository) DeleteAll(uuids []apimongo.UUID) (bool, error)
DeleteAll deletes notifications with IDs and returns true if any record was removed
func (*Repository) DeleteOne ¶
func (r *Repository) DeleteOne(uuid apimongo.UUID) (bool, error)
DeleteOne deletes notification with ID and returns true if record was removed
func (*Repository) GetAll ¶
func (r *Repository) GetAll() ([]Notification, error)
GetAll returns all notifications
func (*Repository) GetOne ¶
func (r *Repository) GetOne(uuid apimongo.UUID) (*Notification, error)
GetOne returns notification by ID or nil