From 8a2c7c03ebf479743ee70a98c9670ddbc61114e8 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Tue, 29 Aug 2017 16:47:12 +1000 Subject: [PATCH] Clarify HTTP RESTful service --- main.go | 4 ++-- restful_router.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index d7a1e47c..592755c6 100644 --- a/main.go +++ b/main.go @@ -195,7 +195,7 @@ func main() { } else { listenAddr := bot.config.Webserver.ListenAddress log.Printf( - "HTTP Webserver support enabled. Listen URL: http://%s:%d/\n", + "HTTP RESTful Webserver support enabled. Listen URL: http://%s:%d/\n", common.ExtractHost(listenAddr), common.ExtractPort(listenAddr), ) router := NewRouter(bot.exchanges) @@ -203,7 +203,7 @@ func main() { } } if !bot.config.Webserver.Enabled { - log.Println("HTTP Webserver support disabled.") + log.Println("HTTP RESTful Webserver support disabled.") } <-bot.shutdown diff --git a/restful_router.go b/restful_router.go index 350ba9c9..d6092671 100644 --- a/restful_router.go +++ b/restful_router.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "net/http" "github.com/gorilla/mux" @@ -15,6 +16,7 @@ func NewRouter(exchanges []exchange.IBotExchange) *mux.Router { allRoutes = append(allRoutes, ConfigRoutes...) allRoutes = append(allRoutes, PortfolioRoutes...) allRoutes = append(allRoutes, WalletRoutes...) + allRoutes = append(allRoutes, IndexRoute...) for _, route := range allRoutes { var handler http.Handler handler = route.HandlerFunc @@ -28,3 +30,18 @@ func NewRouter(exchanges []exchange.IBotExchange) *mux.Router { } return router } + +func getIndex(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, "GoCryptoTrader RESTful interface. For the web GUI, please visit the web GUI readme.") + w.WriteHeader(http.StatusOK) +} + +// IndexRoute maps the index route to the getIndex function +var IndexRoute = Routes{ + Route{ + "", + "GET", + "/", + getIndex, + }, +}