app: add support for debug endpoints
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
86fc1057f7
commit
30e2ec04b7
|
@ -395,6 +395,24 @@ class MoonrakerApp:
|
|||
params['location_prefix'] = location_prefix
|
||||
self.mutable_router.add_handler(pattern, FileUploadHandler, params)
|
||||
|
||||
def register_debug_handler(
|
||||
self,
|
||||
uri: str,
|
||||
request_methods: List[str],
|
||||
callback: APICallback,
|
||||
transports: List[str] = ALL_TRANSPORTS,
|
||||
wrap_result: bool = True
|
||||
) -> None:
|
||||
if not self.server.is_debug_enabled():
|
||||
return
|
||||
if not uri.startswith("/debug"):
|
||||
raise self.server.error(
|
||||
"Debug Endpoints must be registerd in the '/debug' path"
|
||||
)
|
||||
self.register_local_handler(
|
||||
uri, request_methods, callback, transports, wrap_result
|
||||
)
|
||||
|
||||
def remove_handler(self, endpoint: str) -> None:
|
||||
api_def = self.api_cache.pop(endpoint, None)
|
||||
if api_def is not None:
|
||||
|
|
|
@ -88,6 +88,7 @@ class Server:
|
|||
# Tornado Application/Server
|
||||
self.moonraker_app = app = MoonrakerApp(config)
|
||||
self.register_endpoint = app.register_local_handler
|
||||
self.register_debug_endpoint = app.register_debug_handler
|
||||
self.register_static_file_handler = app.register_static_file_handler
|
||||
self.register_upload_handler = app.register_upload_handler
|
||||
self.register_api_transport = app.register_api_transport
|
||||
|
|
Loading…
Reference in New Issue