// internal/api/api.go
package api
import (
"net/http"
"envoy-control-plane/internal"
"envoy-control-plane/internal/pkg/snapshot"
)
const ACME_CALLENGE_WEB_PATH = "/.well-known/acme-challenge"
const html_static_path = "./static"
// RegisterRoutes sets up all the HTTP routes for the REST API.
func RegisterRoutes(mux *http.ServeMux, manager *snapshot.SnapshotManager, enableCertIssuance bool, webrootPath string) {
// Original NewAPI logic is now embedded here, or you can create a simple API struct if needed.
// // Register routes using the manager (e.g., /config, /status)
api := internal.NewAPI(manager, enableCertIssuance, webrootPath) // <- No need for this object
api.RegisterRoutes(mux)
// Handle static files
mux.Handle("/", http.FileServer(http.Dir(html_static_path)))
// ACME challenge handler
if enableCertIssuance {
mux.Handle(ACME_CALLENGE_WEB_PATH+"/", http.FileServer(http.Dir(webrootPath)))
// Log is handled by the server starter
}
}