forked from mailhog/MailHog-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (37 loc) · 977 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
package main
import (
"context"
"flag"
"github.com/labstack/echo/v4"
"time"
"github.com/jay-dee7/MailHog-Server/api"
"github.com/jay-dee7/MailHog-Server/config"
comcfg "github.com/mailhog/MailHog/config"
"github.com/mailhog/http"
)
func configureCliFlags(multiTenant bool) (*config.Config, *comcfg.Config) {
comcfg.RegisterFlags()
config.RegisterFlags()
flag.Parse()
return config.Configure(multiTenant), comcfg.Configure()
}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
conf, comconf := configureCliFlags(true)
if comconf.AuthFile != "" {
http.AuthFile(comconf.AuthFile)
}
apiServerSig := make(chan error)
e := echo.New()
//e.HidePort = true
//e.HidePort = true
defer e.Shutdown(ctx)
router := e.Group("")
api.CreateAPI(conf, router)
go func() {
apiServerSig <- e.Start(conf.APIBindAddr)
}()
//go smtp.Listen(conf)
e.Logger.Printf("api server stopped: %q", <-apiServerSig)
}