diff options
| author | Mathias Magnusson <mathias@magnusson.space> | 2026-01-24 01:57:33 +0100 |
|---|---|---|
| committer | Mathias Magnusson <mathias@magnusson.space> | 2026-01-24 01:57:33 +0100 |
| commit | 39c6170ccab2977bbbaecdde2fdff772f39e2415 (patch) | |
| tree | 97d1d360e8ce62517a573380c0c03362915e55e8 /hh.go | |
| parent | 1fe804770391a644e23eea7c22e0868e3dfb4d2e (diff) | |
| download | hh-main.tar.gz | |
Diffstat (limited to 'hh.go')
| -rw-r--r-- | hh.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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()) + } +} |
