Skip to content

Commit

Permalink
Simplify using custom host
Browse files Browse the repository at this point in the history
  • Loading branch information
smallwat3r committed Sep 12, 2023
1 parent 232fbe6 commit b207754
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions shhh/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class ReadResponse(CallableResponse):
msg: str


def _build_link_url(external_id: str) -> str:
url = app.config.get("SHHH_HOST") or request.url_root
return urljoin(url, url_for("web.read", external_id=external_id))


@dataclass
class WriteResponse(CallableResponse):
"""Schema for outbound write responses."""
Expand All @@ -80,11 +85,7 @@ class WriteResponse(CallableResponse):
details: Message = Message.CREATED

def __post_init__(self):
self.link = urljoin(request.url_root,
url_for("web.read", external_id=self.external_id))
if host_config := app.config["SHHH_HOST"]:
self.link = urljoin(
host_config, url_for("web.read", external_id=self.external_id))
self.link = _build_link_url(self.external_id)


@dataclass
Expand Down

0 comments on commit b207754

Please sign in to comment.