summaryrefslogtreecommitdiff
path: root/examples/basic.go
blob: bfe538ee218941b958bba33efb54397e7cf0db48 (plain) (blame)
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
package main

import (
	"log/slog"
	"net/http"

	"github.com/google/uuid"
)

//go:generate go run git.magnusson.space/hh/cmd/generate

// Big bungus function here!
//
//hh:route GET /org/{orgID}/users
func adminUsersForm(w http.ResponseWriter, r struct {
	r       *http.Request
	search  string    `hh:"form"`
	year    int       `hh:"optional,form"`
	offset  int       `hh:"form"`
	orgID   uuid.UUID `hh:"path"`
	banana  uuid.UUID `hh:"optional,form"`
	nextURL string    `hh:"optional,cookie,logout_next_url"`
}) {
	_, _ = w.Write([]byte("ahahaha"))
	slog.Info("get admin users form", "search", r.search, "offset", r.offset, "next-url", r.nextURL)
}

func main() {
	hhMountRoutes(nil)
	http.ListenAndServe(":http", nil)
}