internal/examples/app/http/pages.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | package http
import (
"net/http"
. "maragu.dev/gomponents"
ghttp "maragu.dev/gomponents/http"
"app/html"
)
func Home(mux *http.ServeMux) {
mux.Handle("GET /", ghttp.Adapt(func(w http.ResponseWriter, r *http.Request) (Node, error) {
// Let's pretend this comes from a db or something.
items := []string{"Super", "Duper", "Nice"}
return html.HomePage(items), nil
}))
}
func About(mux *http.ServeMux) {
mux.Handle("GET /about", ghttp.Adapt(func(w http.ResponseWriter, r *http.Request) (Node, error) {
return html.AboutPage(), nil
}))
}
|