Pack web UI with app into a single binary

This commit is contained in:
Vikram Rangnekar
2019-03-27 22:01:02 -04:00
parent 47b11a14cb
commit d232c3d8a3
7 changed files with 21 additions and 8 deletions

1
serv/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
rice-box.go

View File

@ -8,6 +8,7 @@ import (
"os"
"strings"
rice "github.com/GeertJohan/go.rice"
"github.com/dosco/super-graph/psql"
"github.com/dosco/super-graph/qcode"
"github.com/go-pg/pg"
@ -151,8 +152,8 @@ func InitAndListen() {
http.HandleFunc("/api/v1/graphql", withAuth(apiv1Http))
if conf.GetBool("web_ui") {
fs := http.FileServer(http.Dir("web/build"))
http.Handle("/", fs)
webUI := rice.MustFindBox("../web/build").HTTPBox()
http.Handle("/", http.FileServer(webUI))
}
hp := conf.GetString("host_port")