fix game_code typing
This commit is contained in:
@ -74,11 +74,11 @@ class BaseServlet:
|
|||||||
"""
|
"""
|
||||||
return (False, "")
|
return (False, "")
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
self.logger.warn(f"{game_code} Does not dispatch POST")
|
self.logger.warn(f"{game_code} Does not dispatch POST")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def render_GET(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_GET(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
self.logger.warn(f"{game_code} Does not dispatch GET")
|
self.logger.warn(f"{game_code} Does not dispatch GET")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class ChuniServlet(BaseServlet):
|
|||||||
|
|
||||||
return (f"http://{self.core_cfg.title.hostname}/{game_ver}/", "")
|
return (f"http://{self.core_cfg.title.hostname}/{game_ver}/", "")
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
endpoint = matchers['endpoint']
|
endpoint = matchers['endpoint']
|
||||||
version = int(matchers['version'])
|
version = int(matchers['version'])
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class CardMakerServlet(BaseServlet):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
version = int(matchers['version'])
|
version = int(matchers['version'])
|
||||||
endpoint = matchers['endpoint']
|
endpoint = matchers['endpoint']
|
||||||
req_raw = request.content.getvalue()
|
req_raw = request.content.getvalue()
|
||||||
|
@ -78,7 +78,7 @@ class DivaServlet(BaseServlet):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
req_raw = request.content.getvalue()
|
req_raw = request.content.getvalue()
|
||||||
url_header = request.getAllHeaders()
|
url_header = request.getAllHeaders()
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ class IDZServlet(BaseServlet):
|
|||||||
|
|
||||||
self.logger.info(f"UserDB Listening on port {self.game_cfg.ports.userdb}")
|
self.logger.info(f"UserDB Listening on port {self.game_cfg.ports.userdb}")
|
||||||
|
|
||||||
def render_GET(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_GET(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
url_path = matchers['endpoint']
|
url_path = matchers['endpoint']
|
||||||
self.logger.info(f"IDZ GET request: {url_path}")
|
self.logger.info(f"IDZ GET request: {url_path}")
|
||||||
request.responseHeaders.setRawHeaders(
|
request.responseHeaders.setRawHeaders(
|
||||||
|
@ -155,7 +155,7 @@ class Mai2Servlet(BaseServlet):
|
|||||||
f"Failed to make movie upload directory at {self.game_cfg.uploads.movies_dir}"
|
f"Failed to make movie upload directory at {self.game_cfg.uploads.movies_dir}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def handle_mai2(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def handle_mai2(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
endpoint = matchers['endpoint']
|
endpoint = matchers['endpoint']
|
||||||
version = int(matchers['version'])
|
version = int(matchers['version'])
|
||||||
if endpoint.lower() == "ping":
|
if endpoint.lower() == "ping":
|
||||||
|
@ -132,7 +132,7 @@ class OngekiServlet(BaseServlet):
|
|||||||
f"{self.core_cfg.title.hostname}/",
|
f"{self.core_cfg.title.hostname}/",
|
||||||
)
|
)
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
endpoint = matchers['endpoint']
|
endpoint = matchers['endpoint']
|
||||||
version = matchers['version']
|
version = matchers['version']
|
||||||
if endpoint.lower() == "ping":
|
if endpoint.lower() == "ping":
|
||||||
|
@ -108,7 +108,7 @@ class PokkenServlet(BaseServlet):
|
|||||||
self.game_cfg.ports.admission, PokkenAdmissionFactory(self.core_cfg, self.game_cfg)
|
self.game_cfg.ports.admission, PokkenAdmissionFactory(self.core_cfg, self.game_cfg)
|
||||||
)
|
)
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
content = request.content.getvalue()
|
content = request.content.getvalue()
|
||||||
if content == b"":
|
if content == b"":
|
||||||
self.logger.info("Empty request")
|
self.logger.info("Empty request")
|
||||||
@ -137,7 +137,7 @@ class PokkenServlet(BaseServlet):
|
|||||||
ret = handler(pokken_request)
|
ret = handler(pokken_request)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def handle_matching(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def handle_matching(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
if not self.game_cfg.server.enable_matching:
|
if not self.game_cfg.server.enable_matching:
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class SaoServlet(BaseServlet):
|
|||||||
return (True, "SAO1")
|
return (True, "SAO1")
|
||||||
|
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
req_url = request.uri.decode()
|
req_url = request.uri.decode()
|
||||||
if req_url == "/matching":
|
if req_url == "/matching":
|
||||||
self.logger.info("Matching request")
|
self.logger.info("Matching request")
|
||||||
|
@ -64,8 +64,10 @@ class WaccaServlet:
|
|||||||
def get_endpoint_matchers(self) -> Tuple[List[Tuple[str, str, Dict]], List[Tuple[str, str, Dict]]]:
|
def get_endpoint_matchers(self) -> Tuple[List[Tuple[str, str, Dict]], List[Tuple[str, str, Dict]]]:
|
||||||
return (
|
return (
|
||||||
[],
|
[],
|
||||||
[("render_POST", "/WaccaServlet/api/{api}/{endpoint}", {}),
|
[
|
||||||
("render_POST", "/WaccaServlet/api/{api}/{branch}/{endpoint}", {}),]
|
("render_POST", "/WaccaServlet/api/{api}/{endpoint}", {}),
|
||||||
|
("render_POST", "/WaccaServlet/api/{api}/{branch}/{endpoint}", {})
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -91,7 +93,7 @@ class WaccaServlet:
|
|||||||
|
|
||||||
return (True, f"http://{self.core_cfg.title.hostname}/{game_code}/$v", "")
|
return (True, f"http://{self.core_cfg.title.hostname}/{game_code}/$v", "")
|
||||||
|
|
||||||
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
|
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
|
||||||
def end(resp: Dict) -> bytes:
|
def end(resp: Dict) -> bytes:
|
||||||
hash = md5(json.dumps(resp, ensure_ascii=False).encode()).digest()
|
hash = md5(json.dumps(resp, ensure_ascii=False).encode()).digest()
|
||||||
request.responseHeaders.addRawHeader(b"X-Wacca-Hash", hash.hex().encode())
|
request.responseHeaders.addRawHeader(b"X-Wacca-Hash", hash.hex().encode())
|
||||||
|
Reference in New Issue
Block a user