godash/handlers/routes.go
2024-03-12 15:49:08 +01:00

20 lines
485 B
Go

package handlers
import (
"net/http"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
"github.com/r3labs/sse/v2"
)
func SetupRoutes(e *echo.Echo, sse *sse.Server, bh *AppHandler) {
e.GET("/", bh.appHandler)
e.GET("/sse", echo.WrapHandler(http.HandlerFunc(sse.ServeHTTP)))
}
func renderView(c echo.Context, cmp templ.Component) error {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
return cmp.Render(c.Request().Context(), c.Response().Writer)
}