geo-smart-system/main.go

32 lines
699 B
Go
Raw Normal View History

2019-10-19 16:38:38 +00:00
package main
import (
"github.com/gin-contrib/cors"
2020-11-24 04:36:21 +00:00
"github.com/gin-gonic/autotls"
2019-10-19 16:38:38 +00:00
"github.com/gin-gonic/gin"
"github.com/go-redis/redis"
2020-01-04 00:44:42 +00:00
"github.com/supanadit/geo-smart-system/system"
2020-11-24 04:36:21 +00:00
"golang.org/x/crypto/acme/autocert"
"log"
2019-10-19 16:38:38 +00:00
)
func main() {
2020-01-04 00:44:42 +00:00
// Create Connection with Tile 38
2019-10-19 16:38:38 +00:00
client := redis.NewClient(&redis.Options{
2020-01-04 00:44:42 +00:00
Addr: system.GetTile38ConnectionAddress(),
2019-10-19 16:38:38 +00:00
})
2020-01-04 00:44:42 +00:00
// Create Gin Engine
2019-10-27 16:34:34 +00:00
r := gin.Default()
r.Use(cors.Default())
2020-01-04 00:44:42 +00:00
// Call Router
system.Router(r, client)
// Run Server
2020-11-24 04:36:21 +00:00
m := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(),
Cache: autocert.DirCache("/var/www/.cache"),
}
log.Fatal(autotls.RunWithManager(r, &m))
2019-10-19 16:38:38 +00:00
}