forked from flashmob/go-guerrilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_headers_parser.go
39 lines (36 loc) · 1.27 KB
/
p_headers_parser.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package backends
import (
"github.com/flashmob/go-guerrilla/mail"
)
// ----------------------------------------------------------------------------------
// Processor Name: headersparser
// ----------------------------------------------------------------------------------
// Description : Parses the header using e.ParseHeaders()
// ----------------------------------------------------------------------------------
// Config Options: none
// --------------:-------------------------------------------------------------------
// Input : envelope
// ----------------------------------------------------------------------------------
// Output : Headers will be populated in e.Header
// ----------------------------------------------------------------------------------
func init() {
processors["headersparser"] = func() Decorator {
return HeadersParser()
}
}
func HeadersParser() Decorator {
return func(p Processor) Processor {
return ProcessWith(func(e *mail.Envelope, task SelectTask) (Result, error) {
if task == TaskSaveMail {
if err := e.ParseHeaders(); err != nil {
Log().WithError(err).Error("parse headers error")
}
// next processor
return p.Process(e, task)
} else {
// next processor
return p.Process(e, task)
}
})
}
}