diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-19 14:15:50 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-19 14:15:50 +0200 |
commit | a2a50f3de0c428c5a61e6a449191be3c4ded86ac (patch) | |
tree | 5ecf4f5f1f26933b42a606b741963fa5f66c85aa /commands/webui.go | |
parent | 25fb88d7497b00bbe3dda540efde22ffd3de6e49 (diff) | |
download | git-bug-a2a50f3de0c428c5a61e6a449191be3c4ded86ac.tar.gz |
webui: add a primitive graphql handler
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)) |