package main import ( "errors" "log/slog" "net/http" "git.0m.nu/hh" "github.com/google/uuid" ) //go:generate go run git.0m.nu/hh/cmd/generate // Big bungus function here! // //hh:route GET /org/{orgID}/users func adminUsersForm(r struct { w http.ResponseWriter raw *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"` }) { _, _ = r.w.Write([]byte("ahahaha")) slog.Info("get admin users form", "search", r.search, "offset", r.offset, "next-url", r.nextURL) } //hh:route GET /return-err func returnErr(r struct{ raw *http.Request }) error { _ = r return errors.New("whoops") } //hh:route GET /return-value func returnValue(r struct{ raw *http.Request }) hh.JSONValue { _ = r return hh.JSON(map[string]any{"key": []string{"value", "s"}}) } //hh:route GET /return-both/{which} func returnBoth(r struct { which string `hh:"path"` }) (hh.JSONValue, error) { if r.which == "error" { return hh.JSON(nil), errors.New("whoops") } else { return hh.JSON(map[string]any{"key": []string{"value", "s"}}), nil } } func main() { hhMountRoutes(nil) slog.Error("Error listening", "error", http.ListenAndServe(":http", nil)) }