Parcourir la source

don't need pointer, headerconfig can be local

flashmob il y a 5 ans
Parent
commit
949ff5ce52
2 fichiers modifiés avec 7 ajouts et 7 suppressions
  1. 4 4
      backends/p_header.go
  2. 3 3
      backends/s_header.go

+ 4 - 4
backends/p_header.go

@@ -6,7 +6,7 @@ import (
 	"time"
 )
 
-type HeaderConfig struct {
+type headerConfig struct {
 	PrimaryHost string `json:"primary_mail_host"`
 }
 
@@ -34,15 +34,15 @@ func init() {
 // Sets e.DeliveryHeader part of the envelope with the generated header
 func Header() Decorator {
 
-	var config *HeaderConfig
+	var config *headerConfig
 
 	Svc.AddInitializer(InitializeWith(func(backendConfig BackendConfig) error {
-		configType := BaseConfig(&HeaderConfig{})
+		configType := BaseConfig(&headerConfig{})
 		bcfg, err := Svc.ExtractConfig(ConfigProcessors, "header", backendConfig, configType)
 		if err != nil {
 			return err
 		}
-		config = bcfg.(*HeaderConfig)
+		config = bcfg.(*headerConfig)
 		return nil
 	}))
 

+ 3 - 3
backends/s_header.go

@@ -40,7 +40,7 @@ func newStreamHeader(w io.Writer) *streamHeader {
 	return sc
 }
 
-func (sh *streamHeader) addHeader(e *mail.Envelope, config *HeaderConfig) {
+func (sh *streamHeader) addHeader(e *mail.Envelope, config *headerConfig) {
 	to := strings.TrimSpace(e.RcptTo[0].User) + "@" + config.PrimaryHost
 	hash := "unknown"
 	if len(e.Hashes) > 0 {
@@ -57,7 +57,7 @@ func (sh *streamHeader) addHeader(e *mail.Envelope, config *HeaderConfig) {
 }
 
 func StreamHeader() *StreamDecorator {
-	var hc *HeaderConfig
+	hc := headerConfig{}
 	sd := &StreamDecorator{}
 	sd.Configure = func(cfg ConfigGroup) error {
 		return sd.ExtractConfig(cfg, &hc)
@@ -67,7 +67,7 @@ func StreamHeader() *StreamDecorator {
 			var sh *streamHeader
 			sd.Open = func(e *mail.Envelope) error {
 				sh = newStreamHeader(sp)
-				sh.addHeader(e, hc)
+				sh.addHeader(e, &hc)
 				return nil
 			}
 			return StreamProcessWith(func(p []byte) (int, error) {