-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.go
45 lines (36 loc) · 823 Bytes
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"github.com/RealAlexandreAI/gen-ui-go/component"
"github.com/a-h/templ"
"github.com/gin-gonic/gin"
)
// loadHandlers
//
// @Description:
// @param r
func loadHandlers(r *gin.Engine) {
r.GET("/", func(c *gin.Context) {
metaTags := component.MetaTags(
"gen-ui-go, htmx, templ",
"Generative UI in Golang.",
)
indexTemplate := component.Layout(
"Generative UI in Golang.",
metaTags,
)
_ = indexTemplate.Render(c, c.Writer)
})
componentRouter := r.Group("component")
loadExamples(componentRouter)
}
// loadExamples
//
// @Description:
// @param router
func loadExamples(router *gin.RouterGroup) {
component.ExamplePool.Each(func(key string, value templ.Component) {
router.GET(key, func(c *gin.Context) {
_ = component.Wrap(value).Render(c, c.Writer)
})
})
}