Skip to content

Commit

Permalink
feat: add endpoint to add domain for existing site
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadGenie committed Feb 13, 2025
1 parent 816a4d4 commit c7824be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions agent/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,22 @@ def add_wildcard_hosts(self, wildcards):
if wildcard.get("code_server"):
Path(os.path.join(host_directory, "codeserver")).touch()

@job("Add Site to Upstream")
def add_site_to_upstream_job(self, upstream, site, skip_reload=False):
def add_site_domain_to_upstream(self, upstream, site, skip_reload=False):
self.remove_conflicting_site(site)
self.add_site_to_upstream(upstream, site)
self.generate_proxy_config()
if skip_reload:
return
self.reload_nginx()

@job("Add Site to Upstream")
def add_site_to_upstream_job(self, upstream, site, skip_reload=False):
self.add_site_domain_to_upstream(upstream, site, skip_reload)

@job("Add Domain to Upstream")
def add_domain_to_upstream_job(self, upstream, domain, skip_reload=False):
self.add_site_domain_to_upstream(upstream, domain, skip_reload)

@step("Remove Conflicting Site")
def remove_conflicting_site(self, site):
# Go through all upstreams and remove the site file matching the site name
Expand Down
7 changes: 7 additions & 0 deletions agent/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,13 @@ def proxy_add_upstream_site(upstream):
return {"job": job}


@application.route("/proxy/upstreams/<string:upstream>/domains", methods=["POST"])
def proxy_add_upstream_site_domain(upstream):
data = request.json
job = Proxy().add_domain_to_upstream_job(upstream, data["domain"], data.get("skip_reload", False))
return {"job": job}


@application.route(
"/proxy/upstreams/<string:upstream>/sites/<string:site>",
methods=["DELETE"],
Expand Down

0 comments on commit c7824be

Please sign in to comment.