letters
letters copied to clipboard
Export `letters.ParseHeaders()` so that a message can be parsed into `letters.Headers` only
In https://github.com/mnako/letters/pull/72 @rorycl makes a good point for parsing email headers only: the email bodies might be malformed or the user might be interested in headers only.
I do not think, however, that a string arg letters.ParseEmail(r, "HeadersOnly")
is the best way to implement this feature. I believe that this should be at least a config struct for future maintainability, but for the time being there is a simpler solution: export the ParseHeaders()
identifier so that users can use it directly.
This PR renames letters.parseHeaders()
to letters.ParseHeaders()
, adds a test, and updates README.md with an example.
One point that might merit discussion, is whether the now public ParseHeaders()
should not accept the same parameters as ParseEmail
so that the user is not responsible for reading the message using mail.ReadMessage()
and passing msg.Header
to ParseHeaders()
.