mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
refactor: refactor authentication pages into their own modules
This commit is contained in:
@@ -32,6 +32,28 @@ func Templ(cmp templ.Component) echo.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// TemplEcho renders a component to the response
|
||||
func TemplEcho(c echo.Context, cmp templ.Component) error {
|
||||
// Create a buffer to store the rendered HTML
|
||||
buf := &bytes.Buffer{}
|
||||
// Render the component to the buffer
|
||||
err := cmp.Render(c.Request().Context(), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set the content type
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
// Write the buffered content to the response
|
||||
_, err = c.Response().Write(buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.Response().WriteHeader(200)
|
||||
return nil
|
||||
}
|
||||
|
||||
// / TemplRawBytes renders a component to a byte slice
|
||||
func TemplRawBytes(cmp templ.Component) ([]byte, error) {
|
||||
// Create a buffer to store the rendered HTML
|
||||
|
||||
Reference in New Issue
Block a user