mirror of
https://gitlab.com/ric_harvey/MailHog.git
synced 2024-12-18 10:27:16 +00:00
52 lines
913 B
Go
52 lines
913 B
Go
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|