-
-
Notifications
You must be signed in to change notification settings - Fork 456
/
main.go
38 lines (28 loc) · 960 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 🚀 Fiber is an Express inspired web framework written in Go with 💖
// 📌 API Documentation: https://docs.gofiber.io
// 📝 Github Repository: https://github.com/gofiber/fiber
// Install and configure heroku: https://devcenter.heroku.com/articles/getting-started-with-go#set-up
// You need to read the PORT env from heroku and you need to define the Procfile
// Deploy the app: https://devcenter.heroku.com/articles/getting-started-with-go#deploy-the-app
package main
import (
"log"
"os"
"github.com/gofiber/fiber/v2"
)
func main() {
// Create new Fiber instance
app := fiber.New()
// Create new GET route
app.Get("/", func(ctx *fiber.Ctx) error {
return ctx.SendString("Hello Heroku")
})
// Get the PORT from heroku env
port := os.Getenv("PORT")
// Verify if heroku provided the port or not
if os.Getenv("PORT") == "" {
port = "3000"
}
// Start server on http://${heroku-url}:${port}
log.Fatal(app.Listen(":" + port))
}