forked from aurora-develop/aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (39 loc) · 840 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
45
46
47
package main
import (
"aurora/initialize"
"embed"
"io/fs"
"log"
"net/http"
"os"
"github.com/gin-gonic/gin"
"github.com/acheong08/endless"
"github.com/joho/godotenv"
)
//go:embed web/*
var staticFiles embed.FS
func main() {
gin.SetMode(gin.ReleaseMode)
router := initialize.RegisterRouter()
subFS, err := fs.Sub(staticFiles, "web")
if err != nil {
log.Fatal(err)
}
router.StaticFS("/web", http.FS(subFS))
_ = godotenv.Load(".env")
host := os.Getenv("SERVER_HOST")
port := os.Getenv("SERVER_PORT")
tlsCert := os.Getenv("TLS_CERT")
tlsKey := os.Getenv("TLS_KEY")
if host == "" {
host = "0.0.0.0"
}
if port == "" {
port = "8080"
}
if tlsCert != "" && tlsKey != "" {
_ = endless.ListenAndServeTLS(host+":"+port, tlsCert, tlsKey, router)
} else {
_ = endless.ListenAndServe(host+":"+port, router)
}
}