@@ -41,31 +41,37 @@ func setupRoutes(ctx context.Context, cfg *config.Config, authChecker auth.Check
4141 })
4242 })
4343
44- // Server status
44+ // Server status and config
4545 api .HandleFunc ("/status" , h .Status (ctx ))
46+ api .HandleFunc ("/frontend-config" , h .GetFrontendConfig ())
4647
47- // Loki endpoints
48- api .HandleFunc ("/loki/ready" , h .LokiReady ())
49- api .HandleFunc ("/loki/metrics" , forceCheckAdmin (authChecker , h .LokiMetrics ()))
50- api .HandleFunc ("/loki/buildinfo" , forceCheckAdmin (authChecker , h .LokiBuildInfos ()))
51- api .HandleFunc ("/loki/config/limits" , forceCheckAdmin (authChecker , h .LokiLimits ()))
52- api .HandleFunc ("/loki/flow/records" , h .GetFlows (ctx ))
53- api .HandleFunc ("/loki/export" , h .ExportFlows (ctx ))
48+ if cfg .Static {
49+ // Expose static files only
50+ r .PathPrefix ("/" ).Handler (http .FileServer (http .Dir ("./web/dist/static" )))
51+ } else {
52+ // Loki endpoints
53+ api .HandleFunc ("/loki/ready" , h .LokiReady ())
54+ api .HandleFunc ("/loki/metrics" , forceCheckAdmin (authChecker , h .LokiMetrics ()))
55+ api .HandleFunc ("/loki/buildinfo" , forceCheckAdmin (authChecker , h .LokiBuildInfos ()))
56+ api .HandleFunc ("/loki/config/limits" , forceCheckAdmin (authChecker , h .LokiLimits ()))
57+ api .HandleFunc ("/loki/flow/records" , h .GetFlows (ctx ))
58+ api .HandleFunc ("/loki/export" , h .ExportFlows (ctx ))
5459
55- // Common endpoints
56- api .HandleFunc ("/flow/metrics" , h .GetTopology (ctx ))
57- api .HandleFunc ("/resources/clusters" , h .GetClusters (ctx ))
58- api .HandleFunc ("/resources/udns" , h .GetUDNs (ctx ))
59- api .HandleFunc ("/resources/zones" , h .GetZones (ctx ))
60- api .HandleFunc ("/resources/namespaces" , h .GetNamespaces (ctx ))
61- api .HandleFunc ("/resources/names" , h .GetNames (ctx ))
60+ // Common endpoints
61+ api .HandleFunc ("/flow/metrics" , h .GetTopology (ctx ))
62+ api .HandleFunc ("/resources/clusters" , h .GetClusters (ctx ))
63+ api .HandleFunc ("/resources/udns" , h .GetUDNs (ctx ))
64+ api .HandleFunc ("/resources/zones" , h .GetZones (ctx ))
65+ api .HandleFunc ("/resources/namespaces" , h .GetNamespaces (ctx ))
66+ api .HandleFunc ("/resources/names" , h .GetNames (ctx ))
6267
63- // K8S endpoints
64- api .HandleFunc ("/k8s/resources/udnIds" , h .GetUDNIdss (ctx ))
68+ // K8S endpoints
69+ api .HandleFunc ("/k8s/resources/udnIds" , h .GetUDNIdss (ctx ))
70+
71+ // Frontend files
72+ r .PathPrefix ("/" ).Handler (http .FileServer (http .Dir ("./web/dist/" )))
73+ }
6574
66- // Frontend files
67- api .HandleFunc ("/frontend-config" , h .GetFrontendConfig ())
68- r .PathPrefix ("/" ).Handler (http .FileServer (http .Dir ("./web/dist/" )))
6975 return r
7076}
7177
0 commit comments