diff options
author | reivilibre <oliverw@matrix.org> | 2023-03-23 12:11:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-23 12:11:14 +0000 |
commit | 98fd558382226b347d78e5f6e6782c6e74c25e69 (patch) | |
tree | ec4c7ef0999d40dd47e0c29ac645901b86efd7c5 /synapse/rest/client/_base.py | |
parent | Use immutabledict instead of frozendict (#15113) (diff) | |
download | synapse-98fd558382226b347d78e5f6e6782c6e74c25e69.tar.xz |
Add a primitive helper script for listing worker endpoints. (#15243)
Co-authored-by: Patrick Cloke <patrickc@matrix.org>
Diffstat (limited to 'synapse/rest/client/_base.py')
-rw-r--r-- | synapse/rest/client/_base.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/synapse/rest/client/_base.py b/synapse/rest/client/_base.py index b4cb90cb76..5c1c19e1f3 100644 --- a/synapse/rest/client/_base.py +++ b/synapse/rest/client/_base.py @@ -43,19 +43,22 @@ def client_patterns( Returns: An iterable of patterns. """ - patterns = [] + versions = [] - if unstable: - unstable_prefix = CLIENT_API_PREFIX + "/unstable" - patterns.append(re.compile("^" + unstable_prefix + path_regex)) if v1: - v1_prefix = CLIENT_API_PREFIX + "/api/v1" - patterns.append(re.compile("^" + v1_prefix + path_regex)) - for release in releases: - new_prefix = CLIENT_API_PREFIX + f"/{release}" - patterns.append(re.compile("^" + new_prefix + path_regex)) + versions.append("api/v1") + versions.extend(releases) + if unstable: + versions.append("unstable") + + if len(versions) == 1: + versions_str = versions[0] + elif len(versions) > 1: + versions_str = "(" + "|".join(versions) + ")" + else: + raise RuntimeError("Must have at least one version for a URL") - return patterns + return [re.compile("^" + CLIENT_API_PREFIX + "/" + versions_str + path_regex)] def set_timeline_upper_limit(filter_json: JsonDict, filter_timeline_limit: int) -> None: |