From 6cab167e924a0c8e0f14c599cdb9b87782e7d834 Mon Sep 17 00:00:00 2001 From: Daniel Herman Date: Tue, 8 Mar 2022 13:34:44 -0500 Subject: [PATCH] Add support for deploying to Heroku On Heroku, you have to use the `PORT` environment variable rather than a port of your choice. Prefer using that if available, else default to 8080 --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 25dc6d1..238fb7e 100644 --- a/main.go +++ b/main.go @@ -60,7 +60,13 @@ func main() { e.GET("/.well-known/terraform.json", serviceDiscoveryHandler()) e.GET("/v1/providers/:namespace/:type/*", client.providerHandler()) - _ = e.Start(":8080") + port := os.Getenv("PORT") + + if port == "" { + port = "8080" + } + + _ = e.Start(fmt.Sprintf(":%s", port)) } func serviceDiscoveryHandler() echo.HandlerFunc {