-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (26 loc) · 745 Bytes
/
Copy pathmain.go
File metadata and controls
33 lines (26 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"dashboard/internal/api"
"dashboard/internal/config"
"net/http"
"os"
)
const (
DashboardConfigPathEnvVar = "DASHBOARD_CONFIG_PATH"
)
func main() {
cfg, err := loadConfiguration()
if err != nil {
panic(err)
}
mux := http.NewServeMux()
mux.HandleFunc("GET /api/config", api.ConfigHandler(cfg))
// Serve Static Frontend
mux.Handle("/", http.FileServer(http.Dir("./frontend/dist")))
http.ListenAndServe("[::]:8080", api.CORSMiddleware(mux))
}
// loadConfiguration loads the configuration from the path specified in the DASHBOARD_CONFIG_PATH environment variable
func loadConfiguration() (*config.Config, error) {
configPath := os.Getenv(DashboardConfigPathEnvVar)
return config.LoadConfig(configPath)
}