// gateway is the Lakehouse-Go HTTP/gRPC ingress. In G0 it serves // /health, /v1/ingest (501 stub, per D1.10), and /v1/sql (501 stub). // D6 promotes the stubs to real reverse-proxies with a custom // Director that strips the /v1 prefix before forwarding (per Kimi // finding K2 — httputil.NewSingleHostReverseProxy preserves the // inbound path by default). package main import ( "flag" "log/slog" "net/http" "os" "git.agentview.dev/profit/golangLAKEHOUSE/internal/shared" "github.com/go-chi/chi/v5" ) func main() { configPath := flag.String("config", "lakehouse.toml", "path to TOML config") flag.Parse() cfg, err := shared.LoadConfig(*configPath) if err != nil { slog.Error("config", "err", err) os.Exit(1) } if err := shared.Run("gateway", cfg.Gateway.Bind, func(r chi.Router) { // G0 stubs — D6.1 promotes these to real reverse-proxies via // httputil.ReverseProxy with a Director that strips /v1. r.Post("/v1/ingest", stubHandler) r.Post("/v1/sql", stubHandler) }); err != nil { slog.Error("server", "err", err) os.Exit(1) } } // stubHandler returns 501 with the X-Lakehouse-Stub header so the // D6 promotion is a behavior change (handler swap), not an endpoint // addition. Test clients can detect the stub by header presence. func stubHandler(w http.ResponseWriter, _ *http.Request) { w.Header().Set("X-Lakehouse-Stub", "g0") w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusNotImplemented) _, _ = w.Write([]byte(`{"error":"not implemented in G0; promoted on D6.1"}`)) }