-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (33 loc) · 729 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
41
42
43
44
package main
import (
"embed"
"html/template"
"log"
"net/http"
"os"
"time"
"github.com/gin-gonic/gin"
"github.com/go-logr/logr"
)
//go:embed templates/*
var resources embed.FS
var t = template.Must(template.ParseFS(resources, "templates/*"))
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
routes := gin.Default()
routes.GET("/click", func(c *gin.Context) {
time.sleep(3 * time.Seconds)
c.String(http.StatusOK, "Completed")
})
routes.GET("/", func(c *gin.Context) {
data := map[string]string{
"Region": os.Getenv("FLY_REGION"),
}
t.ExecuteTemplate(w, "index.html.tmpl", data)
})
log.Println("listening on", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}