2023-04-18 09:23:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"examples/bulkupdate"
|
|
|
|
"examples/clicktoedit"
|
2023-04-19 09:55:03 +00:00
|
|
|
"examples/clicktoload"
|
2023-04-19 13:23:56 +00:00
|
|
|
"examples/deleterow"
|
2023-04-18 09:23:18 +00:00
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/a-h/templ"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
if err := run(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func run() error {
|
|
|
|
r := http.NewServeMux()
|
|
|
|
r.Handle("/", templ.Handler(Home(examples)))
|
|
|
|
for _, e := range examples {
|
|
|
|
log.Printf("Serving %q on /%s", e.Name, e.Slug)
|
|
|
|
e.Handlers("/"+e.Slug, r)
|
|
|
|
}
|
|
|
|
log.Println("Listening on localhost:2468")
|
|
|
|
return http.ListenAndServe("localhost:2468", r)
|
|
|
|
}
|
|
|
|
|
|
|
|
type Example struct {
|
|
|
|
Name, Desc, Slug string
|
|
|
|
Handlers func(string, *http.ServeMux)
|
|
|
|
}
|
|
|
|
|
|
|
|
var examples = []Example{
|
|
|
|
{
|
|
|
|
Name: "Click To Edit",
|
|
|
|
Desc: "Demonstrates inline editing of a data object",
|
|
|
|
Slug: "click-to-edit",
|
|
|
|
Handlers: clicktoedit.Handlers,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Bulk Update",
|
|
|
|
Desc: "Demonstrates bulk updating of multiple rows of data",
|
|
|
|
Slug: "bulk-update",
|
|
|
|
Handlers: bulkupdate.Handlers,
|
|
|
|
},
|
2023-04-19 09:55:03 +00:00
|
|
|
{
|
|
|
|
Name: "Click to Load",
|
|
|
|
Desc: "Demonstrates clicking to load more rows in a table",
|
|
|
|
Slug: "click-to-load",
|
|
|
|
Handlers: clicktoload.Handlers,
|
|
|
|
},
|
2023-04-19 13:23:56 +00:00
|
|
|
{
|
|
|
|
Name: "Delete Row",
|
|
|
|
Desc: "Demonstrates row deletion in a table",
|
|
|
|
Slug: "delete-row",
|
|
|
|
Handlers: deleterow.Handlers,
|
|
|
|
},
|
2023-04-18 09:23:18 +00:00
|
|
|
}
|