forked from gofiber/recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (29 loc) · 933 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
39
40
// 🚀 Fiber is an Express inspired web framework written in Go with 💖
// 📌 API Documentation: https://fiber.wiki
// 📝 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"
)
func main() {
// Create new Fiber instance
app := fiber.New()
// Create new GET route
app.Get("/", func(ctx *fiber.Ctx) {
ctx.Send("Hello Heroku")
})
// Get the PORT from heroku env
port := os.Getenv("PORT")
// Verify if heroku provided the port or not
if port == "" {
port = "3000"
log.Print("$PORT == 3000")
}
// Start server on http://${heroku-url}:${port}
app.Listen(port)
}