moonraker: add "GET /server/config" endpoint

Clients may call this method to retrieve moonraker's current configuration in json format.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-02-15 20:01:07 -05:00
parent 0e22a0cfe8
commit f229c3ec2c
1 changed files with 8 additions and 1 deletions

View File

@ -38,7 +38,7 @@ class Server:
error = ServerError
def __init__(self, args, file_logger):
self.file_logger = file_logger
config = confighelper.get_configuration(self, args)
self.config = config = confighelper.get_configuration(self, args)
# log config file
strio = io.StringIO()
config.write_config(strio)
@ -76,6 +76,8 @@ class Server:
self.register_endpoint(
"/server/info", ['GET'], self._handle_info_request)
self.register_endpoint(
"/server/config", ['GET'], self._handle_config_request)
self.register_endpoint(
"/server/restart", ['POST'], self._handle_server_restart)
@ -479,6 +481,11 @@ class Server:
'failed_plugins': self.failed_plugins,
'registered_directories': reg_dirs}
async def _handle_config_request(self, web_request):
return {
'config': self.config.get_parsed_config()
}
class KlippyConnection:
def __init__(self, on_recd, on_close):
self.ioloop = IOLoop.current()