main.go 769 B

1234567891011121314151617181920212223242526272829
  1. package main
  2. import (
  3. "net/http"
  4. "github.com/julienschmidt/httprouter"
  5. "github.com/kubecost/cost-model/pkg/costmodel"
  6. "github.com/kubecost/cost-model/pkg/errors"
  7. "github.com/prometheus/client_golang/prometheus/promhttp"
  8. "github.com/rs/cors"
  9. "k8s.io/klog"
  10. )
  11. func Healthz(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
  12. w.WriteHeader(200)
  13. w.Header().Set("Content-Length", "0")
  14. w.Header().Set("Content-Type", "text/plain")
  15. }
  16. func main() {
  17. a := costmodel.Initialize()
  18. rootMux := http.NewServeMux()
  19. a.Router.GET("/healthz", Healthz)
  20. rootMux.Handle("/", a.Router)
  21. rootMux.Handle("/metrics", promhttp.Handler())
  22. handler := cors.AllowAll().Handler(rootMux)
  23. klog.Fatal(http.ListenAndServe(":9003", errors.PanicHandlerMiddleware(handler)))
  24. }