Skip to content

Commit 27215d2

Browse files
authored
Proxito: inject hosting integration header for build.commands (readthedocs#10219)
* Proxito: inject hosting integration header for `build.commands` Versions using `build.commands` will start using the new Read the Docs JavaScript client. This is still under beta testing, but we want to move forward slowly and start exposing these features to projects that don't have access currently. Related readthedocs/addons#26 * Proxito: check if the version exists first
1 parent d8774cf commit 27215d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

readthedocs/proxito/middleware.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,22 @@ def process_request(self, request): # noqa
281281

282282
def add_hosting_integrations_headers(self, request, response):
283283
project_slug = getattr(request, "path_project_slug", "")
284+
version_slug = getattr(request, "path_version_slug", "")
285+
284286
if project_slug:
285287
project = Project.objects.get(slug=project_slug)
286288
if project.has_feature(Feature.HOSTING_INTEGRATIONS):
287289
response["X-RTD-Hosting-Integrations"] = "true"
288290

291+
# Inject the new integrations for versions using `build.commands`
292+
version = project.versions.filter(slug=version_slug).first()
293+
if (
294+
version
295+
and version.config
296+
and version.config.get("build", {}).get("commands", {}) != []
297+
):
298+
response["X-RTD-Hosting-Integrations"] = "true"
299+
289300
def process_response(self, request, response): # noqa
290301
self.add_proxito_headers(request, response)
291302
self.add_cache_headers(request, response)

0 commit comments

Comments
 (0)