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