Spaces:
Sleeping
Sleeping
File size: 890 Bytes
931bd01 |
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 48 49 50 51 |
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 = os.Getenv("PORT")
if port == "" {
port = "8080"
}
}
if tlsCert != "" && tlsKey != "" {
_ = endless.ListenAndServeTLS(host+":"+port, tlsCert, tlsKey, router)
} else {
_ = endless.ListenAndServe(host+":"+port, router)
}
}
|