app: move reserved endpoints to klippy_connection

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-01-04 05:51:28 -05:00
parent 225ec588eb
commit 019c5fc416
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
2 changed files with 10 additions and 9 deletions

View File

@ -55,12 +55,6 @@ if TYPE_CHECKING:
AuthComp = Optional[components.authorization.Authorization]
APICallback = Callable[[WebRequest], Coroutine]
# These endpoints are reserved for klippy/server communication only and are
# not exposed via http or the websocket
RESERVED_ENDPOINTS = [
"list_endpoints", "gcode/subscribe_output",
"register_remote_method"
]
# 50 MiB Max Standard Body Size
MAX_BODY_SIZE = 50 * 1024 * 1024
@ -321,8 +315,6 @@ class MoonrakerApp:
return self.api_cache
def register_remote_handler(self, endpoint: str) -> None:
if endpoint in RESERVED_ENDPOINTS:
return
api_def = self._create_api_definition(endpoint)
if api_def.uri in self.registered_base_handlers:
# reserved handler or already registered

View File

@ -37,6 +37,14 @@ if TYPE_CHECKING:
from components.machine import Machine
FlexCallback = Callable[..., Optional[Coroutine]]
# These endpoints are reserved for klippy/moonraker communication only and are
# not exposed via http or the websocket
RESERVED_ENDPOINTS = [
"list_endpoints",
"gcode/subscribe_output",
"register_remote_method",
]
INIT_TIME = .25
LOG_ATTEMPT_INTERVAL = int(2. / INIT_TIME + .5)
MAX_LOG_ATTEMPTS = 10 * LOG_ATTEMPT_INTERVAL
@ -318,7 +326,8 @@ class KlippyConnection:
endpoints = result.get('endpoints', [])
app: MoonrakerApp = self.server.lookup_component("application")
for ep in endpoints:
app.register_remote_handler(ep)
if ep not in RESERVED_ENDPOINTS:
app.register_remote_handler(ep)
async def _check_ready(self) -> None:
send_id = "identified" not in self.init_list