42 lines
959 B
Go
42 lines
959 B
Go
package routes
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"html/template"
|
|
"log"
|
|
"net/http"
|
|
|
|
"sunshine.industries/some-automoderation/rooms"
|
|
"sunshine.industries/some-automoderation/sessions"
|
|
)
|
|
|
|
func indexPageRoute(
|
|
templateFs *embed.FS,
|
|
sessionSM sessions.SessionManagement,
|
|
roomsM rooms.RoomManager,
|
|
) http.HandlerFunc {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
var templFile = "templates/index.gohtml"
|
|
session, found := getContextSession(r.Context())
|
|
if !found {
|
|
log.Printf("/ session not found, should be impossible")
|
|
// TODO return error i guess
|
|
}
|
|
data := struct {
|
|
SessionStringToken string
|
|
SomeString string
|
|
SessionToken sessions.SessionData
|
|
}{
|
|
fmt.Sprintf("%+v", session),
|
|
"hello!",
|
|
session,
|
|
}
|
|
tmpl := template.Must(template.ParseFS(templateFs, templFile))
|
|
err := tmpl.Execute(w, data)
|
|
if err != nil {
|
|
log.Printf("my error in executing template, huh\n %s", err)
|
|
}
|
|
})
|
|
}
|