add db connection, refactor code, add db migration files

This commit is contained in:
lbenedar
2026-04-03 18:59:15 +03:00
parent d5577f10d7
commit a16edb9b61
28 changed files with 587 additions and 345 deletions

View File

@@ -1,15 +1,13 @@
package main
import (
"fmt"
"net/http"
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models"
)
func (app *application) ShowText(w http.ResponseWriter, r *http.Request) {
msg := app.foundryApp.CreateWSMessageByPage("/join")
data, err := app.foundryApp.HandleWebsocketRequest(msg)
data, err := app.foundryApp.HandleWSRequest("/join")
if err != nil {
app.slogger.Error("", "error", err)
w.Write([]byte(err.Error()))
@@ -29,8 +27,7 @@ func (app *application) ShowText(w http.ResponseWriter, r *http.Request) {
}
func (app *application) WhenNextSession(w http.ResponseWriter, r *http.Request) {
msg := app.foundryApp.CreateWSMessageByPage("/setup")
data, err := app.foundryApp.HandleWebsocketRequest(msg)
data, err := app.foundryApp.HandleWSRequest("/setup")
if err != nil {
app.slogger.Error("", "error", err)
w.Write([]byte(err.Error()))
@@ -50,7 +47,7 @@ func (app *application) WhenNextSession(w http.ResponseWriter, r *http.Request)
w.Write([]byte(err.Error()))
return
}
fmt.Printf("JSON msg: %s\n", nextSession)
app.slogger.Info("Next session data is ready to send", "sessionTime", nextSession)
w.Write([]byte(nextSession.Local().String()))
}