Documentation
¶
Index ¶
- func RequireIDInURI() gin.HandlerFunc
- func RequireMessageIDInURI() gin.HandlerFunc
- type ApplicationHandler
- func (h *ApplicationHandler) CreateApplication(ctx *gin.Context)
- func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context)
- func (h *ApplicationHandler) GetApplication(ctx *gin.Context)
- func (h *ApplicationHandler) GetApplications(ctx *gin.Context)
- func (h *ApplicationHandler) UpdateApplication(ctx *gin.Context)
- type CredentialsManager
- type Database
- type Dispatcher
- type HealthHandler
- type NotificationDatabase
- type NotificationDispatcher
- type NotificationHandler
- type UserHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequireIDInURI ¶
func RequireIDInURI() gin.HandlerFunc
RequireIDInURI returns a Gin middleware which requires an ID to be supplied in the URI of the request.
func RequireMessageIDInURI ¶
func RequireMessageIDInURI() gin.HandlerFunc
RequireMessageIDInURI returns a Gin middleware which requires an messageID to be supplied in the URI of the request.
Types ¶
type ApplicationHandler ¶
type ApplicationHandler struct {
DB Database
DP Dispatcher
}
ApplicationHandler holds information for processing requests about applications.
func (*ApplicationHandler) CreateApplication ¶
func (h *ApplicationHandler) CreateApplication(ctx *gin.Context)
CreateApplication creates an application.
func (*ApplicationHandler) DeleteApplication ¶
func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context)
DeleteApplication deletes an application with a certain ID.
func (*ApplicationHandler) GetApplication ¶
func (h *ApplicationHandler) GetApplication(ctx *gin.Context)
GetApplication returns the application with the specified ID.
func (*ApplicationHandler) GetApplications ¶
func (h *ApplicationHandler) GetApplications(ctx *gin.Context)
GetApplications returns all applications of the current user.
func (*ApplicationHandler) UpdateApplication ¶
func (h *ApplicationHandler) UpdateApplication(ctx *gin.Context)
UpdateApplication updates an application with a certain ID.
type CredentialsManager ¶
The CredentialsManager interface for updating credentials.
type Database ¶
type Database interface {
Health() error
CreateApplication(application *model.Application) error
DeleteApplication(application *model.Application) error
GetApplicationByID(ID uint) (*model.Application, error)
GetApplicationByToken(token string) (*model.Application, error)
UpdateApplication(application *model.Application) error
AdminUserCount() (int64, error)
CreateUser(user model.CreateUser) (*model.User, error)
DeleteUser(user *model.User) error
GetApplications(user *model.User) ([]model.Application, error)
GetUserByID(ID uint) (*model.User, error)
GetUserByName(name string) (*model.User, error)
GetUsers() ([]model.User, error)
UpdateUser(user *model.User) error
}
The Database interface for encapsulating database access.
type Dispatcher ¶
type Dispatcher interface {
RegisterApplication(id uint, name, token, user string) (string, error)
DeregisterApplication(a *model.Application, u *model.User) error
UpdateApplication(a *model.Application) error
}
The Dispatcher interface for relaying notifications.
type HealthHandler ¶
type HealthHandler struct {
DB Database
}
HealthHandler holds information for processing requests about the server's health.
func (*HealthHandler) Health ¶
func (h *HealthHandler) Health(ctx *gin.Context)
Health returns the health status of the server.
type NotificationDatabase ¶
type NotificationDatabase interface {
}
The NotificationDatabase interface for encapsulating database access.
type NotificationDispatcher ¶
type NotificationDispatcher interface {
SendNotification(a *model.Application, n *model.Notification) (id string, err error)
DeleteNotification(a *model.Application, n *model.DeleteNotification) error
}
The NotificationDispatcher interface for relaying notifications.
type NotificationHandler ¶
type NotificationHandler struct {
DB NotificationDatabase
DP NotificationDispatcher
}
NotificationHandler holds information for processing requests about notifications.
func (*NotificationHandler) CreateNotification ¶
func (h *NotificationHandler) CreateNotification(ctx *gin.Context)
CreateNotification is used to create a new notification for a user.
func (*NotificationHandler) DeleteNotification ¶
func (h *NotificationHandler) DeleteNotification(ctx *gin.Context)
DeleteNotification is used to delete (or mark as deleted) a notification for a user
type UserHandler ¶
type UserHandler struct {
AH *ApplicationHandler
CM CredentialsManager
DB Database
DP Dispatcher
}
UserHandler holds information for processing requests about users.
func (*UserHandler) CreateUser ¶
func (h *UserHandler) CreateUser(ctx *gin.Context)
CreateUser creates a new user. This method assumes that the requesting user has privileges.
func (*UserHandler) DeleteUser ¶
func (h *UserHandler) DeleteUser(ctx *gin.Context)
DeleteUser deletes a user with a certain ID.
This method assumes that the requesting user has privileges.
func (*UserHandler) GetUser ¶
func (h *UserHandler) GetUser(ctx *gin.Context)
GetUser returns the user with the specified ID. This method assumes that the requesting user has privileges.
func (*UserHandler) GetUsers ¶
func (h *UserHandler) GetUsers(ctx *gin.Context)
GetUsers returns all users. This method assumes that the requesting user has privileges.
func (*UserHandler) UpdateUser ¶
func (h *UserHandler) UpdateUser(ctx *gin.Context)
UpdateUser updates a user with a certain ID.
This method assumes that the requesting user has privileges. If users can later update their own user, make sure they cannot give themselves privileges.