Documentation ¶
Overview ¶
Package handlers defines available HTTP handlers
Index ¶
- Constants
- type AccountHandler
- func (h *AccountHandler) Activate(w http.ResponseWriter, r *http.Request) error
- func (h *AccountHandler) Create(w http.ResponseWriter, r *http.Request) error
- func (h *AccountHandler) GetAccountByID(w http.ResponseWriter, r *http.Request) error
- func (h *AccountHandler) GetCloudFeedAuthStatuses(w http.ResponseWriter, r *http.Request) error
- type AdminHandler
- func (h *AdminHandler) Create(admin admin.Admin, token *string) error
- func (h *AdminHandler) Delete(admin admin.Admin, reply *admin.Admin) error
- func (h *AdminHandler) List(input int, reply *[]admin.Admin) error
- func (h *AdminHandler) Middleware(next Handler) Handler
- func (h *AdminHandler) Reactivate(admin admin.Admin, reply *admin.Admin) error
- func (h *AdminHandler) SetExpiry(admin admin.Admin, reply *admin.Admin) error
- type AppHandler
- type AuthorizationHandler
- type BuildingHandler
- type CampaignHandler
- type CloudFeedAuthHandler
- type CloudFeedHandler
- type DeviceHandler
- func (h *DeviceHandler) Activate(w http.ResponseWriter, r *http.Request) error
- func (h *DeviceHandler) Create(w http.ResponseWriter, r *http.Request) error
- func (h *DeviceHandler) GetDeviceByName(w http.ResponseWriter, r *http.Request) error
- func (h *DeviceHandler) GetDeviceMeasurements(w http.ResponseWriter, r *http.Request) error
- func (h *DeviceHandler) GetDeviceProperties(w http.ResponseWriter, r *http.Request) error
- type DeviceTypeHandler
- type DocsHandler
- type DownloadArgs
- type Handler
- type HandlerError
- type UploadHandler
Constants ¶
const AuthorizationCtxKey contextKey = 0
AuthorizationCtxKey is the key for the authorization value that is passed to the context, when the authentication middleware is used.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountHandler ¶
type AccountHandler struct {
// contains filtered or unexported fields
}
func NewAccountHandler ¶
func NewAccountHandler(accountService *services.AccountService) *AccountHandler
func (*AccountHandler) Activate ¶
func (h *AccountHandler) Activate(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for activating an account. This endpoint should be protected with an account activation token.
func (*AccountHandler) Create ¶
func (h *AccountHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new account.
func (*AccountHandler) GetAccountByID ¶
func (h *AccountHandler) GetAccountByID(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting account information.
func (*AccountHandler) GetCloudFeedAuthStatuses ¶
func (h *AccountHandler) GetCloudFeedAuthStatuses(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting connected cloud feed auths.
type AdminHandler ¶
type AdminHandler struct {
// contains filtered or unexported fields
}
AdminHandler can be used in an RPC server. It also has an HTTP middleware to verify admin tokens with admin accounts.
func NewAdminHandler ¶
func NewAdminHandler(service *services.AdminService) *AdminHandler
func (*AdminHandler) Middleware ¶
func (h *AdminHandler) Middleware(next Handler) Handler
HTTP middleware to check if admin in admin auth token is valid.
func (*AdminHandler) Reactivate ¶
type AppHandler ¶
type AppHandler struct {
// contains filtered or unexported fields
}
func NewAppHandler ¶
func NewAppHandler(service *services.AppService) *AppHandler
func (*AppHandler) Create ¶
func (h *AppHandler) Create(w http.ResponseWriter, r *http.Request) error
type AuthorizationHandler ¶
type AuthorizationHandler struct {
// contains filtered or unexported fields
}
func NewAuthorizationHandler ¶
func NewAuthorizationHandler(service *services.AuthorizationService) *AuthorizationHandler
Create a new AuthorizationHandler.
func (*AuthorizationHandler) Middleware ¶
func (h *AuthorizationHandler) Middleware(kind authorization.AuthKind) func(next Handler) Handler
type BuildingHandler ¶
type BuildingHandler struct {
// contains filtered or unexported fields
}
func NewBuildingHandler ¶
func NewBuildingHandler(service *services.BuildingService) *BuildingHandler
Create a new BuildingHandler.
func (*BuildingHandler) GetBuildingByID ¶
func (h *BuildingHandler) GetBuildingByID(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting building information.
type CampaignHandler ¶
type CampaignHandler struct {
// contains filtered or unexported fields
}
func NewCampaignHandler ¶
func NewCampaignHandler(service *services.CampaignService) *CampaignHandler
Create a new CampaignHandler.
func (*CampaignHandler) Create ¶
func (h *CampaignHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new campaign.
type CloudFeedAuthHandler ¶
type CloudFeedAuthHandler struct {
// contains filtered or unexported fields
}
func NewCloudFeedAuthHandler ¶
func NewCloudFeedAuthHandler(service *services.CloudFeedAuthService) *CloudFeedAuthHandler
Create a new CloudFeedAuthHandler.
func (*CloudFeedAuthHandler) Create ¶
func (h *CloudFeedAuthHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new cloud feed.
func (*CloudFeedAuthHandler) Download ¶
func (h *CloudFeedAuthHandler) Download(args DownloadArgs, reply *string) error
Handle RPC endpoint for downloading data from a cloud feed.
type CloudFeedHandler ¶
type CloudFeedHandler struct {
// contains filtered or unexported fields
}
func NewCloudFeedHandler ¶
func NewCloudFeedHandler(service *services.CloudFeedService) *CloudFeedHandler
Create a new CloudFeedHandler.
func (*CloudFeedHandler) Create ¶
func (h *CloudFeedHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new cloud feed.
type DeviceHandler ¶
type DeviceHandler struct {
// contains filtered or unexported fields
}
func NewDeviceHandler ¶
func NewDeviceHandler(service *services.DeviceService) *DeviceHandler
Create a new DeviceHandler.
func (*DeviceHandler) Activate ¶
func (h *DeviceHandler) Activate(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for activating a device.
func (*DeviceHandler) Create ¶
func (h *DeviceHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new device.
func (*DeviceHandler) GetDeviceByName ¶
func (h *DeviceHandler) GetDeviceByName(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting device information.
func (*DeviceHandler) GetDeviceMeasurements ¶
func (h *DeviceHandler) GetDeviceMeasurements(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting device measurements
func (*DeviceHandler) GetDeviceProperties ¶
func (h *DeviceHandler) GetDeviceProperties(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting device properties
type DeviceTypeHandler ¶
type DeviceTypeHandler struct {
// contains filtered or unexported fields
}
func NewDeviceTypeHandler ¶
func NewDeviceTypeHandler(service *services.DeviceTypeService) *DeviceTypeHandler
Create a new DeviceTypeHandler.
func (*DeviceTypeHandler) Create ¶
func (h *DeviceTypeHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new device type.
type DocsHandler ¶
type DocsHandler struct {
// contains filtered or unexported fields
}
func NewDocsHandler ¶
func NewDocsHandler(files fs.FS, baseURL string) (*DocsHandler, error)
Create a new DocsHandler.
func (*DocsHandler) OpenAPISpec ¶
func (h *DocsHandler) OpenAPISpec(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for displaying OpenAPI spec. This file should be displayed as openapi.yml.
func (*DocsHandler) RedirectDocs ¶
func (h *DocsHandler) RedirectDocs(redirectCode int) func(http.ResponseWriter, *http.Request) error
Handle redirection from /docs to /docs/ to serve static files.
type DownloadArgs ¶
type Handler ¶
type Handler func(http.ResponseWriter, *http.Request) error
Handler is an HTTP handler that returns an error.
type HandlerError ¶
type HandlerError struct { Err error ResponseMessage string ResponseCode int LogMessage string LogLevel logrus.Level }
A HandlerError contains information about an error that occured inside a Handler.
func InternalServerError ¶
func InternalServerError(err error) *HandlerError
Helper function to easily create a HandlerError with status 500 (internal server error).
func NewHandlerError ¶
func NewHandlerError(err error, responseMessage string, responseCode int) *HandlerError
Create a new HandlerError. The log level will be set to info.
func (*HandlerError) WithLevel ¶
func (e *HandlerError) WithLevel(level logrus.Level) *HandlerError
Set the log level of a HandlerError.
func (*HandlerError) WithMessage ¶
func (e *HandlerError) WithMessage(message string) *HandlerError
Set the log message of a HandlerError.
type UploadHandler ¶
type UploadHandler struct {
// contains filtered or unexported fields
}
func NewUploadHandler ¶
func NewUploadHandler(service *services.UploadService) *UploadHandler
Create a new UploadHandler.
func (*UploadHandler) Create ¶
func (h *UploadHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new upload.