Updated to BunRouter

This commit is contained in:
2024-01-24 11:22:33 -07:00
parent ab639dec20
commit 8d3f803474
17 changed files with 387 additions and 160 deletions

View File

@ -1,25 +1,16 @@
package pages
import (
"html/template"
"log"
"net/http"
"github.com/labstack/echo/v4"
"github.com/uptrace/bunrouter"
"goth.stack/lib"
)
func SSEDemo(c echo.Context) error {
templates := []string{
"./pages/templates/layouts/base.html",
"./pages/templates/partials/header.html",
"./pages/templates/partials/navitems.html",
"./pages/templates/ssedemo.html",
}
func SSEDemo(w http.ResponseWriter, req bunrouter.Request) error {
// Specify the partials used by this page
partials := []string{"header", "navitems"}
ts, err := template.ParseFiles(templates...)
if err != nil {
log.Print(err.Error())
return err
}
return ts.ExecuteTemplate(c.Response().Writer, "base", nil)
// Render the template
return lib.RenderTemplate(w, "base", partials, nil)
}