Documentation ¶
Overview ¶
Package web implements the REST API handling and routing
Index ¶
- Constants
- Variables
- type DevicesResponse
- type EnrollResponse
- type IdentityService
- func (wb IdentityService) DeleteDevice(context *gin.Context)
- func (wb IdentityService) DeviceGet(context *gin.Context)
- func (wb IdentityService) DeviceList(context *gin.Context)
- func (wb IdentityService) DeviceUpdate(context *gin.Context)
- func (wb IdentityService) EnrollDevice(c *gin.Context)
- func (wb IdentityService) OrganizationList(context *gin.Context)
- func (wb IdentityService) RegisterDevice(context *gin.Context)
- func (wb IdentityService) RegisterOrganization(context *gin.Context)
- func (wb IdentityService) Run() error
- type OrganizationsResponse
- type RegisterResponse
- type StandardResponse
- type Web
Constants ¶
const JSONHeader = "application/json; charset=UTF-8"
JSONHeader is the header for JSON responses
Variables ¶
var Logger = log.StandardLogger()
Logger is a logger specific to the web package and can be swapped out
Functions ¶
This section is empty.
Types ¶
type DevicesResponse ¶
type DevicesResponse struct { StandardResponse Devices []domain.Enrollment `json:"devices"` }
DevicesResponse is the JSON response from a device list API method
type EnrollResponse ¶
type EnrollResponse struct { StandardResponse Enrollment domain.Enrollment `json:"enrollment"` }
EnrollResponse is the JSON response from an enrollment API method
type IdentityService ¶
IdentityService is the implementation of the web API
func NewIdentityService ¶
func NewIdentityService(id service.Identity, l *log.Logger) *IdentityService
NewIdentityService returns a new web controller
func (IdentityService) DeleteDevice ¶
func (wb IdentityService) DeleteDevice(context *gin.Context)
DeleteDevice unregisters a new device with the identity service
func (IdentityService) DeviceGet ¶
func (wb IdentityService) DeviceGet(context *gin.Context)
DeviceGet fetches a device registration
func (IdentityService) DeviceList ¶
func (wb IdentityService) DeviceList(context *gin.Context)
DeviceList fetches device registrations
func (IdentityService) DeviceUpdate ¶
func (wb IdentityService) DeviceUpdate(context *gin.Context)
DeviceUpdate updates a device registration
func (IdentityService) EnrollDevice ¶
func (wb IdentityService) EnrollDevice(c *gin.Context)
EnrollDevice connects an IoT device with the identity service
func (IdentityService) OrganizationList ¶
func (wb IdentityService) OrganizationList(context *gin.Context)
OrganizationList fetches organizations
func (IdentityService) RegisterDevice ¶
func (wb IdentityService) RegisterDevice(context *gin.Context)
RegisterDevice registers a new device with the identity service
func (IdentityService) RegisterOrganization ¶
func (wb IdentityService) RegisterOrganization(context *gin.Context)
RegisterOrganization registers a new organization with the identity service
type OrganizationsResponse ¶
type OrganizationsResponse struct { StandardResponse Organizations []domain.Organization `json:"organizations"` }
OrganizationsResponse is the JSON response from a organization list API method
type RegisterResponse ¶
type RegisterResponse struct { StandardResponse ID string `json:"id"` }
RegisterResponse is the JSON response from a registration API method
type StandardResponse ¶
StandardResponse is the JSON response from an API method, indicating success or failure.
type Web ¶
type Web interface { Run() error InternalRouter(engine *gin.Engine) EnrollRouter(engine *gin.Engine) RegisterOrganization(w http.ResponseWriter, r *http.Request) RegisterDevice(w http.ResponseWriter, r *http.Request) OrganizationList(w http.ResponseWriter, r *http.Request) DeviceList(w http.ResponseWriter, r *http.Request) EnrollDevice(w http.ResponseWriter, r *http.Request) }
Web is the interface for the web API