forked from mailhog/MailHog-UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (44 loc) · 975 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
52
53
54
package main
import (
"flag"
"os"
gohttp "net/http"
"github.com/gorilla/pat"
"github.com/ian-kent/go-log/log"
"github.com/mailhog/MailHog-UI/assets"
"github.com/mailhog/MailHog-UI/config"
"github.com/mailhog/MailHog-UI/web"
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()
// FIXME hacky
web.APIHost = conf.APIHost
}
func main() {
configure()
// FIXME need to make API URL configurable
if comconf.AuthFile != "" {
http.AuthFile(comconf.AuthFile)
}
exitCh = make(chan int)
cb := func(r gohttp.Handler) {
web.CreateWeb(conf, r.(*pat.Router), assets.Asset)
}
go http.Listen(conf.UIBindAddr, assets.Asset, exitCh, cb)
for {
select {
case <-exitCh:
log.Printf("Received exit signal")
os.Exit(0)
}
}
}