summaryrefslogtreecommitdiff
path: root/examples/basic.go
diff options
context:
space:
mode:
authorMathias Magnusson <mathias@magnusson.space>2025-04-10 21:33:41 +0200
committerMathias Magnusson <mathias@magnusson.space>2025-04-10 21:33:41 +0200
commit49bd3e0e0117768138f47f0c97accece15605025 (patch)
tree531306398969bf38fbaff946e5d67d122fa49c6b /examples/basic.go
parentb9bf8a23c75db82e1aff8295a97dcfdf789735f3 (diff)
downloadhh-49bd3e0e0117768138f47f0c97accece15605025.tar.gz
extract value extracting and convertion to functions; support uuid
Diffstat (limited to 'examples/basic.go')
-rw-r--r--examples/basic.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/examples/basic.go b/examples/basic.go
index 856d682..9feaacd 100644
--- a/examples/basic.go
+++ b/examples/basic.go
@@ -1,20 +1,29 @@
-package examples
+package main
import (
"log/slog"
"net/http"
+
+ "github.com/google/uuid"
)
// Big bungus function here!
//
-//hh:route GET /admin/users
+//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"`
- nextURL string `hh:"cookie,logout_next_url"`
+ 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)
+}