Skip to content

Commit

Permalink
Merge pull request #4731 from stsewd/remove-unused-endpoint
Browse files Browse the repository at this point in the history
Remove /cname endpoint
  • Loading branch information
stsewd committed Oct 16, 2018
2 parents 604e1fa + 277c4b2 commit d11402d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 36 deletions.
8 changes: 1 addition & 7 deletions readthedocs/core/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,8 @@ def broadcast(type, task, args, kwargs=None, callback=None): # pylint: disable=
return task_promise


def clean_url(url):
parsed = urlparse(url)
if parsed.scheme or parsed.netloc:
return parsed.netloc
return parsed.path


def cname_to_slug(host):
# TODO: remove
from dns import resolver
answer = [ans for ans in resolver.query(host, 'CNAME')][0]
domain = answer.target.to_unicode()
Expand Down
1 change: 0 additions & 1 deletion readthedocs/restapi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
function_urls = [
url(r'embed/', core_views.embed, name='embed'),
url(r'docurl/', core_views.docurl, name='docurl'),
url(r'cname/', core_views.cname, name='cname'),
url(r'footer_html/', footer_views.footer_html, name='footer_html'),
]

Expand Down
28 changes: 0 additions & 28 deletions readthedocs/restapi/views/core_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,12 @@
from django.core.cache import cache
from django.shortcuts import get_object_or_404

from readthedocs.core.utils import clean_url, cname_to_slug
from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Version
from readthedocs.projects.models import Project
from readthedocs.core.templatetags.core_tags import make_document_url


@decorators.api_view(['GET'])
@decorators.permission_classes((permissions.AllowAny,))
@decorators.renderer_classes((JSONRenderer,))
def cname(request):
"""
Get the slug that a particular hostname resolves to.
This is useful for debugging your DNS settings,
or for getting the backing project name on Read the Docs for a URL.
Example::
GET https://readthedocs.org/api/v2/cname/?host=docs.python-requests.org
This will return information about ``docs.python-requests.org``
"""
host = request.GET.get('host')
if not host:
return Response({'error': 'host GET arg required'}, status=status.HTTP_400_BAD_REQUEST)
host = clean_url(host)
slug = cname_to_slug(host)
return Response({
'host': host,
'slug': slug,
})


@decorators.api_view(['GET'])
@decorators.permission_classes((permissions.AllowAny,))
@decorators.renderer_classes((JSONRenderer,))
Expand Down

0 comments on commit d11402d

Please sign in to comment.