summaryrefslogtreecommitdiff
path: root/hh.go
diff options
context:
space:
mode:
Diffstat (limited to 'hh.go')
-rw-r--r--hh.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/hh.go b/hh.go
index 84df871..a8b7cd4 100644
--- a/hh.go
+++ b/hh.go
@@ -1,6 +1,7 @@
package hh
import (
+ "encoding/json"
"net/http"
"strconv"
@@ -42,3 +43,19 @@ func ConvertToString(value string) (string, error) {
func ConvertToUuidUUID(value string) (uuid.UUID, error) {
return uuid.Parse(value)
}
+
+type ToResponse interface {
+ Respond(w http.ResponseWriter, r *http.Request)
+}
+
+func JSON(a any) JSONValue {
+ return JSONValue{a}
+}
+
+type JSONValue struct{ any }
+
+func (j JSONValue) Respond(w http.ResponseWriter, r *http.Request) {
+ if err := json.NewEncoder(w).Encode(j); err != nil {
+ panic("todo: internal server error: " + err.Error())
+ }
+}