diff options
Diffstat (limited to 'commands/webui.go')
-rw-r--r-- | commands/webui.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/commands/webui.go b/commands/webui.go index 737632c3..af93153a 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "github.com/MichaelMure/git-bug/graphql" "github.com/MichaelMure/git-bug/webui" "github.com/gorilla/mux" "github.com/phayes/freeport" @@ -18,11 +19,23 @@ func runWebUI(cmd *cobra.Command, args []string) error { } addr := fmt.Sprintf("127.0.0.1:%d", port) + webUiAddr := fmt.Sprintf("http://%s", addr) + + fmt.Printf("Web UI available at %s\n", webUiAddr) + + graphqlHandler, err := graphql.NewHandler() + + if err != nil { + return err + } router := mux.NewRouter() + + // Routes + router.Path("/graphql").Handler(graphqlHandler) router.PathPrefix("/").Handler(http.FileServer(webui.WebUIAssets)) - open.Run(fmt.Sprintf("http://%s", addr)) + open.Run(webUiAddr) log.Fatal(http.ListenAndServe(addr, router)) |