blob: dd686c0f73c837948df8c289bf7aaf8abcdcfb86 (
plain)
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"
g "github.com/maragudk/gomponents"
ghttp "github.com/maragudk/gomponents/http"
"app/html"
)
func Home(mux *http.ServeMux) {
mux.Handle("GET /", ghttp.Adapt(func(w http.ResponseWriter, r *http.Request) (g.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) (g.Node, error) {
return html.AboutPage(), nil
}))
}
|