From 5ec7046253e037c0c40783bbc9e9415d26212235 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 18 Dec 2016 08:56:35 -0800 Subject: [PATCH] backend: don't send post bodies to post listing clients --- backend/christine.website/main.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/christine.website/main.go b/backend/christine.website/main.go index a6a29f4..e271802 100644 --- a/backend/christine.website/main.go +++ b/backend/christine.website/main.go @@ -134,7 +134,21 @@ func main() { } func writeBlogPosts(w http.ResponseWriter, r *http.Request) { - json.NewEncoder(w).Encode(posts) + p := []interface{}{} + for _, post := range posts { + p = append(p, struct { + Title string `json:"title"` + Link string `json:"link"` + Summary string `json:"summary,omitifempty"` + Date string `json:"date"` + }{ + Title: post.Title, + Link: post.Link, + Summary: post.Summary, + Date: post.Date, + }) + } + json.NewEncoder(w).Encode(p) } func writeIndexHTML(w http.ResponseWriter, r *http.Request) {