2014-04-20 14:35:59 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2014-11-23 15:05:11 +00:00
|
|
|
"github.com/ian-kent/go-log/log"
|
|
|
|
gotcha "github.com/ian-kent/gotcha/app"
|
2014-12-24 16:52:53 +00:00
|
|
|
"github.com/mailhog/MailHog-Server/config"
|
2014-04-20 14:35:59 +00:00
|
|
|
)
|
|
|
|
|
2014-11-23 15:05:11 +00:00
|
|
|
func Listen(cfg *config.Config, Asset func(string) ([]byte, error), exitCh chan int, registerCallback func(*gotcha.App)) {
|
|
|
|
log.Info("[HTTP] Binding to address: %s", cfg.HTTPBindAddr)
|
2014-04-20 14:35:59 +00:00
|
|
|
|
2014-11-23 15:05:11 +00:00
|
|
|
var app = gotcha.Create(Asset)
|
|
|
|
app.Config.Listen = cfg.HTTPBindAddr
|
|
|
|
|
|
|
|
registerCallback(app)
|
|
|
|
|
|
|
|
app.Start()
|
|
|
|
|
|
|
|
<-make(chan int)
|
|
|
|
exitCh <- 1
|
2014-04-20 14:35:59 +00:00
|
|
|
}
|