From 954be34bc938acc9e14d9fb3b32c8f96cd999959 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 25 Sep 2024 14:02:52 -0500 Subject: http-api: T6736: remove routes on config delete Avoid duplicate entries in the list of routes when adding/deleting endpoints. --- src/services/api/rest/routers.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/services/api/rest/routers.py') diff --git a/src/services/api/rest/routers.py b/src/services/api/rest/routers.py index 1568f7d0c..38b10ef7d 100644 --- a/src/services/api/rest/routers.py +++ b/src/services/api/rest/routers.py @@ -682,4 +682,12 @@ def poweroff_op(data: PoweroffModel): def rest_init(app: "FastAPI"): + if all(r in app.routes for r in router.routes): + return app.include_router(router) + + +def rest_clear(app: "FastAPI"): + for r in router.routes: + if r in app.routes: + app.routes.remove(r) -- cgit v1.2.3