-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
A module implementing connection-arbiter related utilities. | ||
""" | ||
|
||
# internal | ||
from runtimepy.net.arbiter.config import ConfigObject | ||
|
||
|
||
def web_app_paths(config: ConfigObject) -> None: | ||
""" | ||
Register boilerplate path handling for additional application-serving URIs. | ||
""" | ||
|
||
config.setdefault("config", {}) | ||
redirects = config["config"].setdefault("http_redirects", {}) | ||
app_paths = config["config"].setdefault("http_app_paths", []) | ||
|
||
for prefix in config["config"].get("http_app_prefixes", []): | ||
if not prefix.startswith("/"): | ||
prefix = "/" + prefix | ||
|
||
assert not prefix.endswith("/"), prefix | ||
|
||
# Add re-directs. | ||
index_path = f"{prefix}/index.html" | ||
app_path = f"{prefix}/app.html" | ||
redirects.setdefault(prefix, index_path) | ||
redirects.setdefault(index_path, app_path) | ||
|
||
# Add app path. | ||
if app_path not in app_paths: | ||
app_paths.append(app_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters