Skip to content

Commit 6dc6b2b

Browse files
committed
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
1 parent 9cfb649 commit 6dc6b2b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

readthedocs/proxito/middleware.py

+7
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,18 @@ 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.get(slug=version_slug)
293+
if version.config.get("build", {}).get("commands", {}) != []:
294+
response["X-RTD-Hosting-Integrations"] = "true"
295+
289296
def process_response(self, request, response): # noqa
290297
self.add_proxito_headers(request, response)
291298
self.add_cache_headers(request, response)

0 commit comments

Comments
 (0)