From a2a50f3de0c428c5a61e6a449191be3c4ded86ac Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Thu, 19 Jul 2018 14:15:50 +0200 Subject: webui: add a primitive graphql handler --- commands/webui.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'commands/webui.go') 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)) -- cgit