-
Notifications
You must be signed in to change notification settings - Fork 65
/
main.go
51 lines (42 loc) · 913 Bytes
/
main.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
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"os"
gohttp "net/http"
"github.com/ian-kent/go-log/log"
"github.com/mailhog/MailHog-Server/api"
"github.com/mailhog/MailHog-Server/config"
"github.com/mailhog/MailHog-Server/smtp"
"github.com/mailhog/MailHog-UI/assets"
comcfg "github.com/mailhog/MailHog/config"
"github.com/mailhog/http"
)
var conf *config.Config
var comconf *comcfg.Config
var exitCh chan int
func configure() {
comcfg.RegisterFlags()
config.RegisterFlags()
flag.Parse()
conf = config.Configure()
comconf = comcfg.Configure()
}
func main() {
configure()
if comconf.AuthFile != "" {
http.AuthFile(comconf.AuthFile)
}
exitCh = make(chan int)
cb := func(r gohttp.Handler) {
api.CreateAPI(conf, r)
}
go http.Listen(conf.APIBindAddr, assets.Asset, exitCh, cb)
go smtp.Listen(conf, exitCh)
for {
select {
case <-exitCh:
log.Printf("Received exit signal")
os.Exit(0)
}
}
}