mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
RPC server host/port fix (#292)
* Fix to conform with standards on Host header needing a port if its not on port 80 * Fix test to use correct address
This commit is contained in:
@@ -46,7 +46,13 @@ var routes = Routes{}
|
||||
// router
|
||||
func NewRouter() *mux.Router {
|
||||
router := mux.NewRouter().StrictSlash(true)
|
||||
listenAddr := bot.config.Webserver.ListenAddress
|
||||
var listenAddr string
|
||||
|
||||
if common.ExtractPort(bot.config.Webserver.ListenAddress) == 80 {
|
||||
listenAddr = common.ExtractHost(bot.config.Webserver.ListenAddress)
|
||||
} else {
|
||||
listenAddr = bot.config.Webserver.ListenAddress
|
||||
}
|
||||
|
||||
routes = Routes{
|
||||
Route{
|
||||
@@ -117,7 +123,7 @@ func NewRouter() *mux.Router {
|
||||
Path(route.Pattern).
|
||||
Name(route.Name).
|
||||
Handler(RESTLogger(route.HandlerFunc, route.Name)).
|
||||
Host(common.ExtractHost(listenAddr))
|
||||
Host(listenAddr)
|
||||
}
|
||||
|
||||
if bot.config.Profiler.Enabled {
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
)
|
||||
|
||||
@@ -73,7 +72,7 @@ func TestValidHostRequest(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Host = common.ExtractHost(bot.config.Webserver.ListenAddress)
|
||||
req.Host = bot.config.Webserver.ListenAddress
|
||||
|
||||
resp := httptest.NewRecorder()
|
||||
NewRouter().ServeHTTP(resp, req)
|
||||
|
||||
Reference in New Issue
Block a user