package main import ( "fmt" "log" "net/http" "os" "github.com/go-chi/chi" "github.com/go-chi/cors" "github.com/joho/godotenv" ) func main() { godotenv.Load(".env") portStr := os.Getenv("PORT") if portStr == "" { log.Fatal("missing PORT environment variable") } router := chi.NewRouter() router.Use(cors.Handler(cors.Options{ AllowedOrigins: []string{"https://*", "http://*"}, AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowedHeaders: []string{"*"}, ExposedHeaders: []string{"Link"}, AllowCredentials: false, MaxAge: 300, })) v1Router := chi.NewRouter(); v1Router.Get("/healthz", handlerReadiness) v1Router.Get("/err", handleErr) router.Mount("/v1", v1Router) srv := &http.Server{ Handler: router, Addr: ":" + portStr, }; fmt.Printf("Listening on port: %s\n", portStr) err := srv.ListenAndServe(); if err != nil { log.Fatal(err) } } /* GET http://localhost:8080/v1/healthz GET http://localhost:8080/v1/err */