wacca: add .partition()

This commit is contained in:
Hay1tsme 2023-03-09 12:02:02 -05:00
parent a76bb94eb1
commit dafc030050

View File

@ -94,20 +94,24 @@ class WaccaServlet:
version_full = Version(req_json["appVersion"]) version_full = Version(req_json["appVersion"])
except: except:
self.logger.error( self.logger.error(
f"Failed to parse request toi {request.uri} -> {request.content.getvalue()}" f"Failed to parse request to {url_path} -> {request.content.getvalue()}"
) )
resp = BaseResponse() resp = BaseResponse()
resp.status = 1 resp.status = 1
resp.message = "不正なリクエスト エラーです" resp.message = "不正なリクエスト エラーです"
return end(resp.make()) return end(resp.make())
url_split = url_path.split("/") if "/api/" in url_path:
start_req_idx = url_split.index("api") + 1 func_to_find = (
"handle_" + url_path.partition("api/")[2].replace("/", "_") + "_request"
)
func_to_find = "handle_" else:
for x in range(len(url_split) - start_req_idx): self.logger.error(f"Malformed url {url_path}")
func_to_find += f"{url_split[x + start_req_idx]}_" resp = BaseResponse()
func_to_find += "request" resp.status = 1
resp.message = "Bad URL"
return end(resp.make())
ver_search = int(version_full) ver_search = int(version_full)