Documentation ¶
Overview ¶
Package handlers defines available HTTP handlers
Index ¶
- Constants
- type APIKeyHandler
- 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 CampaignHandler
- type CloudFeedHandler
- type CloudFeedTypeHandler
- type DataSourceListHandler
- type DataSourceTypeHandler
- 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
- func (h *DeviceHandler) GetDevicesByAccount(w http.ResponseWriter, r *http.Request) error
- type DeviceTypeHandler
- type DocsHandler
- type DownloadArgs
- type EnergyQueryHandler
- func (h *EnergyQueryHandler) Create(w http.ResponseWriter, r *http.Request) error
- func (h *EnergyQueryHandler) GetEnergyQueriesByAccount(w http.ResponseWriter, r *http.Request) error
- func (h *EnergyQueryHandler) GetEnergyQueryByName(w http.ResponseWriter, r *http.Request) error
- func (h *EnergyQueryHandler) GetEnergyQueryMeasurements(w http.ResponseWriter, r *http.Request) error
- func (h *EnergyQueryHandler) GetEnergyQueryProperties(w http.ResponseWriter, r *http.Request) error
- type EnergyQueryTypeHandler
- 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 APIKeyHandler ¶
type APIKeyHandler struct {
// contains filtered or unexported fields
}
func NewAPIKeyHandler ¶
func NewAPIKeyHandler(service *services.APIKeyService) *APIKeyHandler
Create a new APIKeyHandler.
func (*APIKeyHandler) GetAPIKey ¶
func (h *APIKeyHandler) GetAPIKey(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting an API Key
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) DoubleMiddleware ¶
func (h *AuthorizationHandler) DoubleMiddleware(kind1, kind2 authorization.AuthKind) func(next Handler) Handler
func (*AuthorizationHandler) Middleware ¶
func (h *AuthorizationHandler) Middleware(kind authorization.AuthKind) func(next Handler) Handler
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 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.
func (*CloudFeedHandler) Download ¶
func (h *CloudFeedHandler) Download(args DownloadArgs, reply *string) error
Handle RPC endpoint for downloading data from a cloud feed.
type CloudFeedTypeHandler ¶
type CloudFeedTypeHandler struct {
// contains filtered or unexported fields
}
func NewCloudFeedTypeHandler ¶
func NewCloudFeedTypeHandler(service *services.CloudFeedTypeService) *CloudFeedTypeHandler
Create a new CloudFeedTypeHandler.
func (*CloudFeedTypeHandler) Create ¶
func (h *CloudFeedTypeHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new cloud feed.
type DataSourceListHandler ¶
type DataSourceListHandler struct {
// contains filtered or unexported fields
}
func NewDataSourceListHandler ¶
func NewDataSourceListHandler(service *services.DataSourceListService) *DataSourceListHandler
Create a new DataSourceListHandler.
func (*DataSourceListHandler) Create ¶
func (h *DataSourceListHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new DataSourceList.
type DataSourceTypeHandler ¶
type DataSourceTypeHandler struct {
// contains filtered or unexported fields
}
func NewDataSourceTypeHandler ¶
func NewDataSourceTypeHandler(service *services.DataSourceTypeService) *DataSourceTypeHandler
Create a new DataSourceTypeHandler.
func (*DataSourceTypeHandler) Create ¶
func (h *DataSourceTypeHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new DataSourceType.
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
func (*DeviceHandler) GetDevicesByAccount ¶
func (h *DeviceHandler) GetDevicesByAccount(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting devices by account including uploads (Former building)
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 DownloadArgs struct { AccountID uint CloudFeedID uint StartPeriod needforheat.Time EndPeriod needforheat.Time }
type EnergyQueryHandler ¶
type EnergyQueryHandler struct {
// contains filtered or unexported fields
}
func NewEnergyQueryHandler ¶
func NewEnergyQueryHandler(service *services.EnergyQueryService) *EnergyQueryHandler
Create a new EnergyQueryHandler.
func (*EnergyQueryHandler) Create ¶
func (h *EnergyQueryHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new energy query.
func (*EnergyQueryHandler) GetEnergyQueriesByAccount ¶
func (h *EnergyQueryHandler) GetEnergyQueriesByAccount(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting EnergyQueries by account including uploads (Former building)
func (*EnergyQueryHandler) GetEnergyQueryByName ¶
func (h *EnergyQueryHandler) GetEnergyQueryByName(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting EnergyQuery information.
func (*EnergyQueryHandler) GetEnergyQueryMeasurements ¶
func (h *EnergyQueryHandler) GetEnergyQueryMeasurements(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting EnergyQuery measurements
func (*EnergyQueryHandler) GetEnergyQueryProperties ¶
func (h *EnergyQueryHandler) GetEnergyQueryProperties(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for getting EnergyQuery properties
type EnergyQueryTypeHandler ¶
type EnergyQueryTypeHandler struct {
// contains filtered or unexported fields
}
func NewEnergyQueryTypeHandler ¶
func NewEnergyQueryTypeHandler(service *services.EnergyQueryTypeService) *EnergyQueryTypeHandler
Create a new EnergyQueryTypeHandler.
func (*EnergyQueryTypeHandler) Create ¶
func (h *EnergyQueryTypeHandler) Create(w http.ResponseWriter, r *http.Request) error
Handle API endpoint for creating a new device type.
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.