geo-smart-system/main.go

29 lines
708 B
Go
Raw Normal View History

2019-10-19 16:38:38 +00:00
package main
import (
"fmt"
2019-10-19 16:38:38 +00:00
"github.com/gin-contrib/cors"
"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 05:12:27 +00:00
"log"
"net/http"
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:46:42 +00:00
// _ = r.Run(fmt.Sprintf(":%s", system.ServerPort))
2020-11-24 05:12:27 +00:00
// _ = r.RunTLS(fmt.Sprintf(":%s", system.ServerPort), "./server.crt", "./server.key")
err := http.ListenAndServeTLS(fmt.Sprintf(":%s", system.ServerPort), "cert.pem", "key.pem", nil)
log.Fatal(err)
2019-10-19 16:38:38 +00:00
}