diff options
author | John Estabrook <jestabro@vyos.io> | 2024-09-25 14:02:52 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-09-29 22:21:21 -0500 |
commit | 954be34bc938acc9e14d9fb3b32c8f96cd999959 (patch) | |
tree | ddc8b084bde5d5002b0547fcf7807d829f6e1d56 /src/services/api/rest/routers.py | |
parent | fc9885f859617bab36c971f4eaa56240741f52c4 (diff) | |
download | vyos-1x-954be34bc938acc9e14d9fb3b32c8f96cd999959.tar.gz vyos-1x-954be34bc938acc9e14d9fb3b32c8f96cd999959.zip |
http-api: T6736: remove routes on config delete
Avoid duplicate entries in the list of routes when adding/deleting
endpoints.
Diffstat (limited to 'src/services/api/rest/routers.py')
-rw-r--r-- | src/services/api/rest/routers.py | 8 |
1 files changed, 8 insertions, 0 deletions
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) |