Remove fiber ctx from render

This commit is contained in:
Eden Kirin
2024-02-06 20:36:27 +01:00
parent 320fb3c4d3
commit a47e8a39b6
5 changed files with 10 additions and 12 deletions

19
app/handlers/helpers.go Normal file
View File

@ -0,0 +1,19 @@
package handlers
import (
"fiber-sessions/app/router/requests"
"github.com/a-h/templ"
"github.com/gofiber/fiber/v2/middleware/adaptor"
)
type RequestHandler = func(request *requests.Request) error
// example taken from https://github.com/a-h/templ/tree/main/examples/integration-gofiber
func Render(request *requests.Request, component templ.Component, options ...func(*templ.ComponentHandler)) error {
componentHandler := templ.Handler(component)
for _, o := range options {
o(componentHandler)
}
return adaptor.HTTPHandler(componentHandler)(request.Ctx)
}