From d8ac1d78b058c8f2fe9fd7d7bec6d2bec4e719a6 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Fri, 11 Oct 2013 16:40:06 -0700 Subject: [PATCH] Change format of json msg header --- bin/mailbox-source.sh | 1 + web/mailbox_controller.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100755 bin/mailbox-source.sh diff --git a/bin/mailbox-source.sh b/bin/mailbox-source.sh new file mode 100755 index 0000000..cbff7e6 --- /dev/null +++ b/bin/mailbox-source.sh @@ -0,0 +1 @@ +curl -i -H "Accept: application/json" --noproxy localhost http://localhost:9000/mailbox/source/$1/$2 diff --git a/web/mailbox_controller.go b/web/mailbox_controller.go index 018a18b..ecff8ae 100644 --- a/web/mailbox_controller.go +++ b/web/mailbox_controller.go @@ -7,10 +7,12 @@ import ( "io" "net/http" "strconv" + "time" ) type JsonMessageHeader struct { - From, Subject, Date string + Mailbox, Id, From, Subject string + Date time.Time } func MailboxIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) { @@ -45,9 +47,11 @@ func MailboxList(w http.ResponseWriter, req *http.Request, ctx *Context) (err er jmessages := make([]*JsonMessageHeader, len(messages)) for i, msg := range messages { jmessages[i] = &JsonMessageHeader{ + Mailbox: name, + Id: msg.Id(), From: msg.From(), Subject: msg.Subject(), - Date: msg.Date().String(), + Date: msg.Date(), } } return RenderJson(w, jmessages)