implement basic web server for dashboard,
use templates to do basic SSR on head and header
This commit is contained in:
28
app/utils.go
Normal file
28
app/utils.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port int `json:"listenPort"`
|
||||
Organization string `json:"organization"`
|
||||
PVE string `json:"pveurl"`
|
||||
API string `json:"apiurl"`
|
||||
Page string
|
||||
}
|
||||
|
||||
func GetConfig(configPath string) Config {
|
||||
content, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
log.Fatal("Error when opening config file: ", err)
|
||||
}
|
||||
var config Config
|
||||
err = json.Unmarshal(content, &config)
|
||||
if err != nil {
|
||||
log.Fatal("Error during parsing config file: ", err)
|
||||
}
|
||||
return config
|
||||
}
|
Reference in New Issue
Block a user