diff options
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()) + } +} |
