web

package
v0.0.0-...-f1366d8 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

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

JSONHeader is the header for JSON responses

Variables

This section is empty.

Functions

func Logger

func Logger(start time.Time, r *http.Request)

Logger Handle logging for the web service

func Middleware

func Middleware(inner http.Handler) http.Handler

Middleware to pre-process web service requests

Types

type AppConfig

type AppConfig struct {
	SnapVersion    string        `json:"snapVersion"`
	FactoryReset   bool          `json:"factoryReset"`
	SnapControl    bool          `json:"snapControl"`
	HideInterfaces []string      `json:"hideInterfaces"`
	Custom         config.Custom `json:"custom"`
}

AppConfig holds the config for application

type AppConfigResponse

type AppConfigResponse struct {
	StandardResponse
	Services interface{} `json:"config"`
}

AppConfigResponse the JSON response from a app config call

type InterfaceConfig

type InterfaceConfig struct {
	Use         bool     `json:"use"`
	IsWifi      bool     `json:"isWifi"`
	Method      string   `json:"method"`
	Interface   string   `json:"interface"`
	NameServers []string `json:"nameServers"`
	Address     string   `json:"address"`
	Mask        string   `json:"mask"`
	Gateway     string   `json:"gateway"`
	SSID        string   `json:"ssid"`
	Password    string   `json:"password"`
}

InterfaceConfig defines the configuration of an interface

type LoginResponse

type LoginResponse struct {
	StandardResponse
	Username  string `json:"username"`
	SessionID string `json:"sessionId"`
}

LoginResponse is the response message from a login action

type NetworkResponse

type NetworkResponse struct {
	StandardResponse
	Interfaces []InterfaceConfig `json:"interfaces"`
}

NetworkResponse the JSON response from a network call

type ProxyConfig

type ProxyConfig struct {
	HTTP  string `json:"http,omitempty"`
	HTTPS string `json:"https,omitempty"`
	FTP   string `json:"ftp,omitempty"`
}

ProxyConfig holds the config for proxy servers

type ProxyResponse

type ProxyResponse struct {
	StandardResponse
	Proxy interface{} `json:"proxy"`
}

ProxyResponse the JSON response from a proxy config call

type RecordResponse

type RecordResponse struct {
	StandardResponse
	Record interface{} `json:"record"`
}

RecordResponse the JSON response from a get call

type RecordsResponse

type RecordsResponse struct {
	StandardResponse
	Records interface{} `json:"records"`
}

RecordsResponse the JSON response from a list call

type ServiceResponse

type ServiceResponse struct {
	StandardResponse
	Services interface{} `json:"services"`
}

ServiceResponse the JSON response from a app services call

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 SystemResources

type SystemResources struct {
	CPU    float64 `json:"cpu"`
	Memory float64 `json:"memory"`
	Disk   float64 `json:"disk"`
}

SystemResources is the monitor of system resources

type TimeConfig

type TimeConfig struct {
	NTP      bool   `json:"ntp"`
	Time     string `json:"time"`
	Timezone string `json:"timezone"`
}

TimeConfig allows update of the time config

type TimeResponse

type TimeResponse struct {
	StandardResponse
	Time interface{} `json:"time"`
}

TimeResponse the JSON response from a time config call

type Web

type Web struct {
	Settings    *config.Settings
	Auth        service.AuthService
	NetSrv      network.Service
	Snapd       snapd.Client
	TimeSrv     service.TimeService
	SystemSrv   system.Service
	TransferSrv transfer.Service
}

Web implements the web service

func NewWebService

func NewWebService(settings *config.Settings, auth service.AuthService, network network.Service, snapd snapd.Client, t service.TimeService, sys system.Service, xfer transfer.Service) *Web

NewWebService starts a new web service

func (Web) AppConfig

func (srv Web) AppConfig(w http.ResponseWriter, r *http.Request)

AppConfig is the API to get the application config

func (Web) AppServices

func (srv Web) AppServices(w http.ResponseWriter, r *http.Request)

AppServices is the API to get the current application service status

func (Web) AuthCheck

func (srv Web) AuthCheck(r *http.Request) (*datastore.Session, error)

AuthCheck checks that we have an active session cookie

func (Web) FactoryReset

func (srv Web) FactoryReset(w http.ResponseWriter, r *http.Request)

FactoryReset triggers a factory reset on the device

func (Web) Index

func (srv Web) Index(w http.ResponseWriter, r *http.Request)

Index is the front page of the web application

func (Web) Login

func (srv Web) Login(w http.ResponseWriter, r *http.Request)

Login is the login web page

func (Web) Logout

func (srv Web) Logout(w http.ResponseWriter, r *http.Request)

Logout is the logout web page to remove the session cookie

func (Web) MiddlewareWithAuth

func (srv Web) MiddlewareWithAuth(inner http.Handler) http.Handler

MiddlewareWithAuth handles authentication and redirects to the login page

func (Web) Network

func (srv Web) Network(w http.ResponseWriter, r *http.Request)

Network is the API to get the network interface config

func (Web) NetworkApply

func (srv Web) NetworkApply(w http.ResponseWriter, r *http.Request)

NetworkApply is the API to apply the current network configuration

func (Web) NetworkInterface

func (srv Web) NetworkInterface(w http.ResponseWriter, r *http.Request)

NetworkInterface is the API to store the network interface configuration

func (Web) Proxy

func (srv Web) Proxy(w http.ResponseWriter, r *http.Request)

Proxy is the API to get the proxy config

func (Web) ProxyUpdate

func (srv Web) ProxyUpdate(w http.ResponseWriter, r *http.Request)

ProxyUpdate is the API to update the proxy config

func (Web) Router

func (srv Web) Router() *mux.Router

Router returns the application router

func (Web) SnapList

func (srv Web) SnapList(w http.ResponseWriter, r *http.Request)

SnapList list the installed snaps

func (Web) SnapSet

func (srv Web) SnapSet(w http.ResponseWriter, r *http.Request)

SnapSet updates the config of a snap

func (Web) Start

func (srv Web) Start() error

Start the web service

func (Web) StartOnInterface

func (srv Web) StartOnInterface(iface string) error

StartOnInterface starts the web service on a specific network interface

func (Web) SystemResources

func (srv Web) SystemResources(w http.ResponseWriter, r *http.Request)

SystemResources monitors the system resources

func (Web) Time

func (srv Web) Time(w http.ResponseWriter, r *http.Request)

Time is the API for fetching the time config

func (Web) TimeConfig

func (srv Web) TimeConfig(w http.ResponseWriter, r *http.Request)

TimeConfig is the API for configuring the time

func (Web) TransferExport

func (srv Web) TransferExport(w http.ResponseWriter, r *http.Request)

TransferExport generates a file to export the current configuration

func (Web) TransferImport

func (srv Web) TransferImport(w http.ResponseWriter, r *http.Request)

TransferImport gets an import configuration file and configures the current system

Jump to

Keyboard shortcuts

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