REST API: add a method to get the status of the services

added a status page to the built-in web admin
This commit is contained in:
Nicola Murino
2020-12-08 11:18:34 +01:00
parent 6977a4a18b
commit 50982229e1
22 changed files with 424 additions and 71 deletions

View File

@@ -23,6 +23,13 @@ var (
server *webDavServer
)
// ServiceStatus defines the service status
type ServiceStatus struct {
IsActive bool `json:"is_active"`
Address string `json:"address"`
Protocol string `json:"protocol"`
}
// Cors configuration
type Cors struct {
AllowedOrigins []string `json:"allowed_origins" mapstructure:"allowed_origins"`
@@ -70,7 +77,15 @@ type Configuration struct {
Cache Cache `json:"cache" mapstructure:"cache"`
}
// Initialize configures and starts the WebDav server
// GetStatus returns the server status
func GetStatus() ServiceStatus {
if server == nil {
return ServiceStatus{}
}
return server.status
}
// Initialize configures and starts the WebDAV server
func (c *Configuration) Initialize(configDir string) error {
var err error
logger.Debug(logSender, "", "initializing WebDAV server with config %+v", *c)