Use URL path for args, not get params
This commit is contained in:
parent
b341320e37
commit
f8170d8751
2 changed files with 4 additions and 3 deletions
|
@ -22,8 +22,9 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
if parsed.path.startswith("/api/"):
|
if parsed.path.startswith("/api/"):
|
||||||
_, _, endpoint = parsed.path[1:].partition("/")
|
_, _, endpoint = parsed.path[1:].partition("/")
|
||||||
|
endpoint, _, args = endpoint.partition("/")
|
||||||
response = _events.on("api").on(endpoint).call_for_result(
|
response = _events.on("api").on(endpoint).call_for_result(
|
||||||
params=get_params, path=endpoint.split("/"))
|
params=get_params, path=args.split("/"))
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
response = json.dumps(response, sort_keys=True,
|
response = json.dumps(response, sort_keys=True,
|
||||||
|
|
|
@ -63,8 +63,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
@utils.hook("api.channels")
|
@utils.hook("api.channels")
|
||||||
def channels_api(self, event):
|
def channels_api(self, event):
|
||||||
print(event["path"])
|
print(event["path"])
|
||||||
if "server-id" in event["params"]:
|
if event["path"]:
|
||||||
server_id = event["params"]["server-id"][0]
|
server_id = event["path"][0]
|
||||||
if not server_id.isdigit():
|
if not server_id.isdigit():
|
||||||
return None
|
return None
|
||||||
server_id = int(server_id)
|
server_id = int(server_id)
|
||||||
|
|
Loading…
Reference in a new issue