package main import ( "log" "net/http" "os" "time" "git.netflux.io/rob/netflux-homepage/handler" ) const ( readTimeout = time.Second * 3 writeTimeout = time.Second * 3 defaultListenAddr = ":9000" ) func main() { matrixHostname := os.Getenv("NETFLUX_MATRIX_HOSTNAME") matrixBaseURL := os.Getenv("NETFLUX_MATRIX_BASE_URL") rootPath := os.Getenv("NETFLUX_ROOT_PATH") if matrixHostname == "" || matrixBaseURL == "" || rootPath == "" { log.Fatal("NETFLUX_MATRIX_HOSTNAME and NETFLUX_MATRIX_BASE_URL and NETFLUX_ROOT_PATH are all required") } listenAddr := os.Getenv("NETFLUX_LISTEN_ADDR") if listenAddr == "" { listenAddr = defaultListenAddr } server := http.Server{ Addr: listenAddr, Handler: handler.New(handler.Params{ MatrixHostname: matrixHostname, MatrixBaseURL: matrixBaseURL, RootPath: rootPath, }), ReadTimeout: readTimeout, WriteTimeout: writeTimeout, } if err := server.ListenAndServe(); err != nil { log.Fatalf("server error: %v", err) } }