-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (27 loc) · 807 Bytes
/
Copy pathmain.go
File metadata and controls
34 lines (27 loc) · 807 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
34
package main
import (
"certui/internal/api"
"certui/internal/config"
"net/http"
"os"
)
const (
CertuiConfigPathEnvVar = "CERTUI_CONFIG_PATH"
)
func main() {
cfg, err := loadConfiguration()
if err != nil {
panic(err)
}
mux := http.NewServeMux()
mux.HandleFunc("GET /api/endpoints", api.AllEndpointsHandler(cfg))
mux.HandleFunc("GET /api/endpoints-sse", api.EndpointHandlerSSE(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 CERTUI_CONFIG_PATH environment variable
func loadConfiguration() (*config.Config, error) {
configPath := os.Getenv(CertuiConfigPathEnvVar)
return config.LoadConfig(configPath)
}