better castle

This commit is contained in:
metacryst
2025-09-22 13:05:06 -05:00
parent 04f4155a19
commit a58632d983
10 changed files with 3293 additions and 114 deletions

View File

@@ -5,6 +5,7 @@ import (
"net/http"
"path/filepath"
"hyperia/config"
"hyperia/db"
"hyperia/handlers"
"hyperia/logger"
"runtime/debug"
@@ -16,15 +17,14 @@ import (
func main() {
config.SetConfiguration()
logger.ConfigureLogger()
// err := handlers.InitDB()
// if err != nil {
// log.Fatal().Msgf("failed to connect to database: %v", err)
// } else {
// log.Info().Msg("successfully connected to PostgreSQL")
// }
err := db.InitDB()
if err != nil {
log.Fatal().Msgf("failed to connect to database: %v", err)
} else {
log.Info().Msg("successfully connected to PostgreSQL")
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
defer func() {
@@ -55,7 +55,7 @@ func main() {
})
log.Info().Msgf("Server starting on http://localhost: %s", config.PORT)
err := http.ListenAndServe(":"+config.PORT, nil)
err = http.ListenAndServe(":"+config.PORT, nil)
if err != nil {
log.Fatal().Msgf("failed to start server: %v", err)
}
@@ -67,10 +67,6 @@ func handlePublic(w http.ResponseWriter, r *http.Request) {
handlers.HandleLogin(w, r)
return
}
if r.URL.Path == "/api/applicantlogin" {
handlers.HandleApplicantLogin(w, r)
return
}
if r.URL.Path == "/api/join" {
handlers.HandleJoin(w, r)
return