fix: refactor and fix inbound email handling#388
Conversation
Codecov Report
@@ Coverage Diff @@
## master #388 +/- ##
===========================================
+ Coverage 72.47% 95.23% +22.75%
===========================================
Files 3 3
Lines 476 399 -77
===========================================
+ Hits 345 380 +35
+ Misses 127 14 -113
- Partials 4 5 +1
Continue to review full report at Codecov.
|
|
Need to update the README. We can no longer do |
thinkingserious
left a comment
There was a problem hiding this comment.
Awesome refactor! 🥇
thinkingserious
left a comment
There was a problem hiding this comment.
We can now delete conf.json since the Heroku deploy functionality is removed.
Not sure if this is in scope (perhaps we create a separate issue for this), but it feels like we should have at least one working "hello inbound email" email example. Something simple, like the following:
package main
import (
"fmt"
"log"
"net/http"
"github.com/sendgrid/sendgrid-go/helpers/inbound"
)
func inboundHandler(response http.ResponseWriter, request *http.Request) {
parsedEmail := Parse(response, request)
fmt.Print(parsedEmail.Headers["From"])
for filename, contents := range parsedEmail.Attachments {
// Do something with an attachment
handleAttachment(filename, contents)
}
for section, body := range parsedEmail.Body {
// Do something with the email body
handleEmail(body)
}
}
func main() {
http.HandleFunc("/inbound", inboundHandler)
if err := http.ListenAndServe(":8000", nil); err != nil {
log.Fatalln("Error")
}
}|
Woohoo: |
Fixes #383