Skip to content

Commit 277c4b2

Browse files
committed
Remove /cname endpoint
1 parent 35695d1 commit 277c4b2

File tree

3 files changed

+1
-36
lines changed

3 files changed

+1
-36
lines changed

readthedocs/core/utils/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,8 @@ def broadcast(type, task, args, kwargs=None, callback=None): # pylint: disable=
6161
return task_promise
6262

6363

64-
def clean_url(url):
65-
parsed = urlparse(url)
66-
if parsed.scheme or parsed.netloc:
67-
return parsed.netloc
68-
return parsed.path
69-
70-
7164
def cname_to_slug(host):
65+
# TODO: remove
7266
from dns import resolver
7367
answer = [ans for ans in resolver.query(host, 'CNAME')][0]
7468
domain = answer.target.to_unicode()

readthedocs/restapi/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
function_urls = [
6666
url(r'embed/', core_views.embed, name='embed'),
6767
url(r'docurl/', core_views.docurl, name='docurl'),
68-
url(r'cname/', core_views.cname, name='cname'),
6968
url(r'footer_html/', footer_views.footer_html, name='footer_html'),
7069
]
7170

readthedocs/restapi/views/core_views.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,12 @@
1313
from django.core.cache import cache
1414
from django.shortcuts import get_object_or_404
1515

16-
from readthedocs.core.utils import clean_url, cname_to_slug
1716
from readthedocs.builds.constants import LATEST
1817
from readthedocs.builds.models import Version
1918
from readthedocs.projects.models import Project
2019
from readthedocs.core.templatetags.core_tags import make_document_url
2120

2221

23-
@decorators.api_view(['GET'])
24-
@decorators.permission_classes((permissions.AllowAny,))
25-
@decorators.renderer_classes((JSONRenderer,))
26-
def cname(request):
27-
"""
28-
Get the slug that a particular hostname resolves to.
29-
30-
This is useful for debugging your DNS settings,
31-
or for getting the backing project name on Read the Docs for a URL.
32-
33-
Example::
34-
35-
GET https://readthedocs.org/api/v2/cname/?host=docs.python-requests.org
36-
37-
This will return information about ``docs.python-requests.org``
38-
"""
39-
host = request.GET.get('host')
40-
if not host:
41-
return Response({'error': 'host GET arg required'}, status=status.HTTP_400_BAD_REQUEST)
42-
host = clean_url(host)
43-
slug = cname_to_slug(host)
44-
return Response({
45-
'host': host,
46-
'slug': slug,
47-
})
48-
49-
5022
@decorators.api_view(['GET'])
5123
@decorators.permission_classes((permissions.AllowAny,))
5224
@decorators.renderer_classes((JSONRenderer,))

0 commit comments

Comments
 (0)