get REST API port from settings if it's not in Host header
This commit is contained in:
parent
d2de2cca7d
commit
a02bfdf157
1 changed files with 6 additions and 2 deletions
|
@ -77,11 +77,15 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||||
|
|
||||||
def url_for(self, headers, route, endpoint, get_params={}):
|
def url_for(self, headers, route, endpoint, get_params={}):
|
||||||
if "Host" in headers:
|
if "Host" in headers:
|
||||||
host = headers["Host"]
|
host, _, port = headers["Host"].partition(":")
|
||||||
|
if not port:
|
||||||
|
port = _bot.config.get("api-port", "5000")
|
||||||
|
|
||||||
get_params_str = ""
|
get_params_str = ""
|
||||||
if get_params:
|
if get_params:
|
||||||
get_params_str = "?%s" % urllib.parse.urlencode(get_params)
|
get_params_str = "?%s" % urllib.parse.urlencode(get_params)
|
||||||
return "%s/%s/%s%s" % (host, route, endpoint, get_params_str)
|
return "%s:%d/%s/%s%s" % (host, port, route, endpoint,
|
||||||
|
get_params_str)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
def _url_for(self, headers):
|
def _url_for(self, headers):
|
||||||
|
|
Loading…
Reference in a new issue