Use admin_patterns for all admin APIs. (#8331)

This reduces duplication of the admin prefix in regular expressions.
This commit is contained in:
Patrick Cloke 2020-09-17 07:04:15 -04:00 committed by GitHub
parent 53284c425e
commit c3c9732c53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 26 deletions

View file

@ -44,7 +44,7 @@ def historical_admin_path_patterns(path_regex):
]
def admin_patterns(path_regex: str):
def admin_patterns(path_regex: str, version: str = "v1"):
"""Returns the list of patterns for an admin endpoint
Args:
@ -54,7 +54,7 @@ def admin_patterns(path_regex: str):
Returns:
A list of regex patterns.
"""
admin_prefix = "^/_synapse/admin/v1"
admin_prefix = "^/_synapse/admin/" + version
patterns = [re.compile(admin_prefix + path_regex)]
return patterns