Changed existing octoprint.server.http.* hooks to prefix routes with /plugin/<identifier>/
This will hopefully prevent conflicting routes between multiple plugins from being registered and also ensures a more consistent behaviour compared to BlueprintPlugin mixins. Thanks to @Salandora for bringing this up.
This commit is contained in:
1 parent
3823216319
commit
ceb0e29da3
2 files changed
+25
-4
No files matched your search
@@ -785,8 +785,11 @@ class Server():
|
||||
if not isinstance(entry[2], dict):
|
||||
continue
|
||||
|
||||
self._logger.debug("Adding additional route {route} handled by handler {handler} and with additional arguments {args!r}".format(route=entry[0], handler=entry[1], args=entry[2]))
|
||||
server_routes.append(entry)
|
||||
route, handler, kwargs = entry
|
||||
route = r"/plugin/{name}/{route}".format(name=name, route=route if not route.startswith("/") else route[1:])
|
||||
|
||||
self._logger.debug("Adding additional route {route} handled by handler {handler} and with additional arguments {kwargs!r}".format(**locals()))
|
||||
server_routes.append((route, handler, kwargs))
|
||||
|
||||
server_routes.append((r".*", util.tornado.UploadStorageFallbackHandler, dict(fallback=util.tornado.WsgiInputContainer(app.wsgi_app), file_prefix="octoprint-file-upload-", file_suffix=".tmp", suffixes=upload_suffixes)))
|
||||
|
||||
@@ -811,8 +814,11 @@ class Server():
|
||||
if not isinstance(entry[2], int):
|
||||
continue
|
||||
|
||||
self._logger.debug("Adding maximum body size of {size}B for {method} requests to {path} (Plugin: {name})".format(method=entry[0], path=entry[1], size=entry[2], name=name))
|
||||
max_body_sizes.append(entry)
|
||||
method, route, size = entry
|
||||
route = r"/plugin/{name}/{route}".format(name=name, route=route if not route.startswith("/") else route[1:])
|
||||
|
||||
self._logger.debug("Adding maximum body size of {size}B for {method} requests to {route})".format(**locals()))
|
||||
max_body_sizes.append((method, route, size))
|
||||
|
||||
self._server = util.tornado.CustomHTTPServer(self._tornado_app, max_body_sizes=max_body_sizes, default_max_body_size=settings().getInt(["server", "maxSize"]))
|
||||
self._server.listen(self._port, address=self._host)
|
||||
|
||||
Reference in new issue
Block a user