api

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShowUI

func ShowUI(rw http.ResponseWriter, req *http.Request)

ShowUI redirects to the '/ui/' virtual directory

Types

type ErrorResponse added in v1.0.37

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse represents an API response

type Hub

type Hub struct {

	// Inbound messages from the connections.
	Broadcast chan []byte
	// contains filtered or unexported fields
}

Hub is a connection hub for websockets

func NewHub

func NewHub() *Hub

NewHub is a constructor for new connection Hubs

type RemoveConfigRequest added in v1.0.39

type RemoveConfigRequest struct {
	Name string `json:"name"`
}

RemoveConfigRequest represents a 'remove config' request

type Service

type Service struct {
	DB         *data.Manager
	StartTime  time.Time
	HistoryTTL time.Duration

	// WsHub is the websocket hub connection for
	// broadcasting config changes to anybody interested
	WsHub *Hub
}

Service encapsulates API service operations

func (Service) GetAllConfig

func (service Service) GetAllConfig(rw http.ResponseWriter, req *http.Request)

GetAllConfig godoc @Summary Gets all config items @Description Gets all config items @Tags config @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /config [get]

func (Service) GetAllEvents added in v1.0.36

func (service Service) GetAllEvents(rw http.ResponseWriter, req *http.Request)

GetAllEvents godoc @Summary Gets all events in the system @Description Gets all events in the system @Tags events @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /events [get]

func (Service) GetConfig

func (service Service) GetConfig(rw http.ResponseWriter, req *http.Request)

GetConfig gets a specfic config item based on config item name

func (Service) GetEvent added in v1.0.36

func (service Service) GetEvent(rw http.ResponseWriter, req *http.Request)

GetEvent godoc @Summary Gets a log event. @Description Gets a log event. @Tags events @Accept json @Produce json @Param id path string true "The event id to get" @Success 200 {object} api.SystemResponse @Failure 404 {object} api.ErrorResponse @Router /event/{id} [get]

func (Service) RemoveConfig

func (service Service) RemoveConfig(rw http.ResponseWriter, req *http.Request)

RemoveConfig godoc @Summary Removes a specific config item and broadcasts the change on the websocket @Description Removes a specific config item and broadcasts the change on the websocket @Tags config @Accept json @Produce json @Param config body api.RemoveConfigRequest true "The config item to remove" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /config [delete]

func (Service) SetConfig

func (service Service) SetConfig(rw http.ResponseWriter, req *http.Request)

SetConfig godoc @Summary Sets a specific config item and broadcasts the change on the websocket @Description Sets a specific config item and broadcasts the change on the websocket @Tags config @Accept json @Produce json @Param config body api.SetConfigRequest true "The config item to update" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /config [post]

type SetConfigRequest added in v1.0.39

type SetConfigRequest struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

SetConfigRequest represents a 'set config' request

type SystemResponse

type SystemResponse struct {
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

SystemResponse is a response for a system request

type WsHandler

type WsHandler struct {
	H *Hub
}

WsHandler websocket handler

func (WsHandler) ServeHTTP

func (wsh WsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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