mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-15 23:16:48 +00:00
Clarify HTTP RESTful service
This commit is contained in:
4
main.go
4
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
|
||||
|
||||
@@ -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, "<html>GoCryptoTrader RESTful interface. For the web GUI, please visit the <a href=https://github.com/thrasher-/gocryptotrader/blob/master/web/README.md>web GUI readme.</a></html>")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
// IndexRoute maps the index route to the getIndex function
|
||||
var IndexRoute = Routes{
|
||||
Route{
|
||||
"",
|
||||
"GET",
|
||||
"/",
|
||||
getIndex,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user