package routes import ( "embed" "fmt" "html/template" "log" "net/http" "sunshine.industries/some-automoderation/rooms" "sunshine.industries/some-automoderation/sessions" ) func renderIndexPage(session sessions.SessionData, w http.ResponseWriter) { var baseFile = "templates/base.gohtml" var templFile = "templates/index.gohtml" type MainData struct { SessionStringToken string SomeString string SessionToken sessions.SessionData } data := pageData{ Base: baseData{ Title: "hello base template title", }, Header: headerData{ Title: session.RoomId, }, Content: MainData{ fmt.Sprintf("%+v", session), "hello!", session, }, } tmpl := template.Must(template.ParseFS(templateFs, templFile, baseFile)) err := tmpl.ExecuteTemplate(w, "full-page", data) if err != nil { log.Printf("my error in executing template, huh\n %s", err) } } func indexPageRoute( templateFs *embed.FS, sessionSM sessions.SessionManagement, roomsM rooms.RoomManager, ) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { session, found := getContextSession(r.Context()) if !found { log.Printf("/ session not found, should be impossible") // TODO return error i guess } renderIndexPage(session, w) }) }