about summary refs log tree commit diff stats
path: root/internal/examples/app/http/pages.go
blob: a8756f7e54a0e494f1fcd6fa2d0d5da103c015c5 (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"

	. "go.alanpearce.eu/gomponents"
	ghttp "go.alanpearce.eu/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
	}))
}