finish world initialization, set up init on startup and on shutdown, move all models to main directory
This commit is contained in:
@@ -1,37 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
func (app *application) ShowText(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := app.foundryApp.Test()
|
||||
dbConn := app.foundryApp.Transport.DB
|
||||
|
||||
world, err := db.GetWorld(dbConn, "kingmaker")
|
||||
if err != nil {
|
||||
app.slogger.Error("", "error", err)
|
||||
w.Write([]byte(err.Error()))
|
||||
w.Write([]byte("Got error"))
|
||||
return
|
||||
}
|
||||
|
||||
var dbGame db.Game
|
||||
|
||||
start := time.Now()
|
||||
data.ToDB(&dbGame)
|
||||
elapsed := time.Since(start)
|
||||
|
||||
app.slogger.Info("Game data successfully parsed", "elapsedtime", elapsed)
|
||||
|
||||
byteData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
app.slogger.Error("", "error", err)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
w.Write(byteData)
|
||||
w.Write([]byte(fmt.Sprintf("Got world with name %s, core_version - %s, next_session - %v", world.ID, world.CoreVersion, world.NextSession)))
|
||||
}
|
||||
|
||||
func (app *application) WhenNextSession(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user