http

package
v0.0.0-...-1a0b003 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIURLDevices    = "/api/devices/v1/deviceconnect"
	APIURLInternal   = "/api/internal/v1/deviceconnect"
	APIURLManagement = "/api/management/v1/deviceconnect"

	APIURLDevicesConnect = APIURLDevices + "/connect"

	APIURLInternalAlive     = APIURLInternal + "/alive"
	APIURLInternalHealth    = APIURLInternal + "/health"
	APIURLInternalShutdown  = APIURLInternal + "/shutdown"
	APIURLInternalDevices   = APIURLInternal + "/tenants/:tenantId/devices"
	APIURLInternalDevicesID = APIURLInternal +
		"/tenants/:tenantId/devices/:deviceId"
	APIURLInternalDevicesIDCheckUpdate = APIURLInternal +
		"/tenants/:tenantId/devices/:deviceId/check-update"
	APIURLInternalDevicesIDSendInventory = APIURLInternal +
		"/tenants/:tenantId/devices/:deviceId/send-inventory"

	APIURLManagementDevice              = APIURLManagement + "/devices/:deviceId"
	APIURLManagementDeviceConnect       = APIURLManagement + "/devices/:deviceId/connect"
	APIURLManagementDeviceDownload      = APIURLManagement + "/devices/:deviceId/download"
	APIURLManagementDeviceCheckUpdate   = APIURLManagement + "/devices/:deviceId/check-update"
	APIURLManagementDeviceSendInventory = APIURLManagement + "/devices/:deviceId/send-inventory"
	APIURLManagementDeviceUpload        = APIURLManagement + "/devices/:deviceId/upload"
	APIURLManagementPlayback            = APIURLManagement + "/sessions/:sessionId/playback"

	HdrKeyOrigin = "Origin"
)

API URL used by the HTTP router

View Source
const (
	PropertyOffset = "offset"
)
View Source
const (
	PropertyUserID = "user_id"
)

Variables

View Source
var (
	ErrMissingUserAuthentication = errors.New(
		"missing or non-user identity in the authorization headers",
	)
	ErrMsgSessionLimit = "session byte limit exceeded"

	//The name of the field holding a number of milliseconds to sleep between
	//the consecutive writes of session recording data. Note that it does not have
	//anything to do with the sleep between the keystrokes send, lines printed,
	//or screen blinks, we are only aware of the stream of bytes.
	PlaybackSleepIntervalMsField = "sleep_ms"

	//The name of the field in the query parameter to GET that holds the id of a session
	PlaybackSessionIDField = "sessionId"
)

HTTP errors

View Source
var (
	ErrMissingAuthentication = errors.New(
		"missing or non-device identity in the authorization headers",
	)
)

HTTP errors

Functions

func IdentityMiddleware

func IdentityMiddleware(c *gin.Context)

IdentityMiddleware is a gin middleware which extracts the identity from the JWT token

func NewError

func NewError(err error, code int) error

func NewRouter

func NewRouter(
	app app.App,
	natsClient nats.Client,
	config *RouterConfig,
) (*gin.Engine, error)

NewRouter returns the gin router

func SetAcceptedOrigins

func SetAcceptedOrigins(origins []string)

Types

type DeviceController

type DeviceController struct {
	// contains filtered or unexported fields
}

DeviceController container for end-points

func NewDeviceController

func NewDeviceController(
	app app.App,
	natsClient nats.Client,
) *DeviceController

NewDeviceController returns a new DeviceController

func (DeviceController) Connect

func (h DeviceController) Connect(c *gin.Context)

Connect starts a websocket connection with the device

func (DeviceController) ConnectServeWS

func (h DeviceController) ConnectServeWS(
	ctx context.Context,
	conn *websocket.Conn,
) (err error)

func (DeviceController) Delete

func (h DeviceController) Delete(c *gin.Context)

Delete responds to DELETE /tenants/:tenantId/devices/:deviceId

func (DeviceController) Provision

func (h DeviceController) Provision(c *gin.Context)

Provision responds to POST /tenants/:tenantId/devices

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Error

func (err *Error) Error() string

func (*Error) Unwrap

func (err *Error) Unwrap() error

type InternalController

type InternalController struct {
	// contains filtered or unexported fields
}

InternalController contains status-related end-points

func NewInternalController

func NewInternalController(app app.App, nc nats.Client) *InternalController

NewInternalController returns a new InternalController

func (InternalController) CheckUpdate

func (h InternalController) CheckUpdate(c *gin.Context)

func (InternalController) SendInventory

func (h InternalController) SendInventory(c *gin.Context)

type ManagementController

type ManagementController struct {
	// contains filtered or unexported fields
}

ManagementController container for end-points

func NewManagementController

func NewManagementController(
	app app.App,
	nc nats.Client,
) *ManagementController

NewManagementController returns a new ManagementController

func (ManagementController) CheckUpdate

func (h ManagementController) CheckUpdate(c *gin.Context)

func (ManagementController) Connect

func (h ManagementController) Connect(c *gin.Context)

Connect extracts identity from request, checks user permissions and calls ConnectDevice

func (ManagementController) ConnectServeWS

func (h ManagementController) ConnectServeWS(
	ctx context.Context,
	conn *websocket.Conn,
	sess *model.Session,
	deviceChan chan *natsio.Msg,
) (err error)

ConnectServeWS starts a websocket connection with the device Currently this handler only properly handles a single terminal session.

func (ManagementController) DownloadFile

func (h ManagementController) DownloadFile(c *gin.Context)

func (ManagementController) GetDevice

func (h ManagementController) GetDevice(c *gin.Context)

GetDevice returns a device

func (ManagementController) Playback

func (h ManagementController) Playback(c *gin.Context)

func (ManagementController) SendInventory

func (h ManagementController) SendInventory(c *gin.Context)

func (ManagementController) UploadFile

func (h ManagementController) UploadFile(c *gin.Context)

type RouterConfig

type RouterConfig struct {
	GracefulShutdownTimeout time.Duration
}

type StatusController

type StatusController struct {
	// contains filtered or unexported fields
}

StatusController contains status-related end-points

func NewStatusController

func NewStatusController(app app.App, gracefulShutdownTimeout time.Duration) *StatusController

NewStatusController returns a new StatusController

func (StatusController) Alive

func (h StatusController) Alive(c *gin.Context)

Alive responds to GET /alive

func (StatusController) Health

func (h StatusController) Health(c *gin.Context)

Health responds to GET /health

func (StatusController) Shutdown

func (h StatusController) Shutdown(c *gin.Context)

Shutdown responds to GET /shutdown

Jump to

Keyboard shortcuts

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