echo-todos/helper.go

22 lines
438 B
Go
Raw Normal View History

2024-08-19 12:56:20 +00:00
package main
import (
"context"
"net/http"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
_ "github.com/mattn/go-sqlite3"
)
func render(ctx echo.Context, status int, t templ.Component) error {
ctx.Response().Writer.WriteHeader(status)
err := t.Render(context.Background(), ctx.Response().Writer)
if err != nil {
return ctx.String(http.StatusInternalServerError, "failed to render response template")
}
return nil
}