web

package
v0.0.0-...-aa5a986 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2022 License: AGPL-3.0 Imports: 16 Imported by: 3

Documentation

Overview

Package web implements the REST API handling and routing

Index

Constants

View Source
const JSONHeader = "application/json; charset=UTF-8"

JSONHeader is the header for JSON responses

Variables

View Source
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

type IdentityService struct {
	Identity service.Identity
	// contains filtered or unexported fields
}

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

func (IdentityService) Run

func (wb IdentityService) Run() error

Run starts the web 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

type StandardResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL