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={}):
|
||||
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 = ""
|
||||
if 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:
|
||||
return None
|
||||
def _url_for(self, headers):
|
||||
|
|
Loading…
Reference in a new issue