Add -headless option

This commit is contained in:
Peter Stuifzand 2018-12-09 16:30:02 +01:00
parent d997fa8ca9
commit f21a68a56d
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -40,6 +40,7 @@ var (
pool *redis.Pool
port int
authEnabled bool
headless bool
redisServer = flag.String("redis", "redis:6379", "")
)
@ -48,6 +49,7 @@ func init() {
flag.IntVar(&port, "port", 80, "port for serving api")
flag.BoolVar(&authEnabled, "auth", true, "use auth")
flag.BoolVar(&headless, "headless", false, "disable frontend")
}
func newPool(addr string) *redis.Pool {
@ -140,11 +142,14 @@ func main() {
http.Handle("/incoming/", &incomingHandler{
Backend: &hubBackend,
})
handler, err := newMainHandler(backend.(*memoryBackend))
if err != nil {
log.Fatal(err)
if !headless {
handler, err := newMainHandler(backend.(*memoryBackend))
if err != nil {
log.Fatal(err)
}
http.Handle("/", handler)
}
http.Handle("/", handler)
backend.(*memoryBackend).run()
hubBackend.run()