You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
683 B
39 lines
683 B
package main |
|
|
|
import ( |
|
"flag" |
|
"github.com/joho/godotenv" |
|
"html/template" |
|
"net/http" |
|
"os" |
|
"systemdesigngame/internal/auth" |
|
"systemdesigngame/internal/server" |
|
"systemdesigngame/router" |
|
) |
|
|
|
func main() { |
|
devMode := flag.Bool("dev", false, "load .env (local dev)") |
|
flag.Parse() |
|
|
|
if *devMode { |
|
if err := godotenv.Load(); err != nil { |
|
panic("failed to load .env") |
|
} |
|
|
|
} |
|
|
|
// set up JWT secret used for authentication |
|
auth.JwtSecret = []byte(os.Getenv("JWT_SECRET")) |
|
tmpl := template.Must(template.ParseGlob("static/*.html")) |
|
|
|
server.InitApp() |
|
|
|
mux := app.SetupRoutes(tmpl) |
|
|
|
srv := &http.Server{ |
|
Addr: ":8080", |
|
Handler: mux, |
|
} |
|
|
|
server.GracefulShutdown(srv) |
|
}
|
|
|