diff --git a/controller.go b/controller.go index 52957d3..11484a4 100644 --- a/controller.go +++ b/controller.go @@ -3,6 +3,7 @@ package main import ( "database/sql" "encoding/base64" + "encoding/json" "fmt" "log" "net/http" @@ -55,8 +56,15 @@ func (h *Handler) getRsvps(w http.ResponseWriter, r *http.Request) { return } + marshalledRsvps, err := json.Marshal(rsvps) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + fmt.Fprintf(w, "%s", err.Error()) + return + } + w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, "%#v", rsvps) + fmt.Fprintf(w, "%s", marshalledRsvps) } func (h *Handler) createRsvp(w http.ResponseWriter, r *http.Request) {