mirror of
https://github.com/1f349/lotus.git
synced 2024-12-21 15:44:12 +00:00
Allow default config structs
This commit is contained in:
parent
a21b4c4871
commit
31186402f7
@ -6,8 +6,8 @@ import (
|
||||
)
|
||||
|
||||
type Conf struct {
|
||||
Listen string `yaml:"listen"`
|
||||
Audience string `yaml:"audience"`
|
||||
SendMail *sendmail.Smtp `yaml:"sendmail"`
|
||||
Imap *imap.Imap `yaml:"imap"`
|
||||
Listen string `yaml:"listen"`
|
||||
Audience string `yaml:"audience"`
|
||||
SendMail sendmail.SendMail `yaml:"sendmail"`
|
||||
Imap imap.Imap `yaml:"imap"`
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func main() {
|
||||
}
|
||||
|
||||
userAuth := api.CheckAuth(verify, conf.Audience)
|
||||
srv := api.SetupApiServer(conf.Listen, userAuth, conf.SendMail, conf.Imap)
|
||||
srv := api.SetupApiServer(conf.Listen, userAuth, &conf.SendMail, &conf.Imap)
|
||||
log.Printf("[Lotus] Starting API server on: '%s'\n", srv.Addr)
|
||||
go utils.RunBackgroundHttp("Lotus", srv)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type Smtp struct {
|
||||
type SendMail struct {
|
||||
SendMailCommand string `json:"send_mail_command"`
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ type Mail struct {
|
||||
|
||||
var execCommand = exec.Command
|
||||
|
||||
func (s *Smtp) Send(mail *Mail) error {
|
||||
func (s *SendMail) Send(mail *Mail) error {
|
||||
// start sendmail caller
|
||||
if s.SendMailCommand == "" {
|
||||
s.SendMailCommand = "/usr/sbin/sendmail"
|
||||
|
@ -55,7 +55,7 @@ func TestSmtp_Send(t *testing.T) {
|
||||
listen, err := net.ListenUnix("", addr)
|
||||
assert.NoError(t, err)
|
||||
|
||||
s := &Smtp{SendMailCommand: "/tmp/sendmailXXXXX"}
|
||||
s := &SendMail{SendMailCommand: "/tmp/sendmailXXXXX"}
|
||||
assert.NoError(t, s.Send(m))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user