22 lines
438 B
Go
22 lines
438 B
Go
|
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
|
||
|
}
|