Skip to content
This repository has been archived by the owner on May 6, 2018. It is now read-only.

Commit

Permalink
Added starting the EmailQueue to the top of boardinator;
Browse files Browse the repository at this point in the history
Added async email.SaveAndSend() within the SendEmail
POST handler and changed the response to 'added
to the queue' rather than 'sent successfully';

related to #26 #20
  • Loading branch information
ajvb committed Feb 21, 2014
1 parent eca48af commit 785c7de
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions boardinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func main() {
if err := server.ListenAndServe(); err != nil {
log.Printf("HTTP listen failed: %v\n", err)
}

// Start the Email Queue
types.StartEmailQueue()
}

func SimpleHTTPServer(handler http.Handler, host string) *http.Server {
Expand Down Expand Up @@ -242,13 +245,15 @@ func SendEmail(w http.ResponseWriter, r *http.Request) {
return
}

if err = e.Save(); err != nil {
writeError(w, err, 500)
return
}
go e.SaveAndSend()

go e.Send()
// TODO
// How about we return to them the saved *Email (as JSON) so
// they have the ID and as to return immediately. We can then
// save a corresponding EmailStatus object (see #19) then allow
// them to query the server to check the status (perhaps via
// GET requests to /email/{id}/status).

w.Header().Set("Content-Type", "application/json; charset=utf-8")
fmt.Fprintf(w, `{"response": "Email sent successfully!"}`)
fmt.Fprintf(w, `{"response": "Email added to the queue."}`)
}

0 comments on commit 785c7de

Please sign in to comment.