prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Search json endpoint is not available in new front-end
  **Summary**
  https://twitter.com/klaascuvelier/status/1182203293117886464
  
  
  **Steps To Reproduce (STR)**
  _How can we reproduce the problem?_
  
  Go to https://developer.mozilla.org/en-US/search.json?q=array
   
  
  
  **Actual behavior**
  Blank page
  
  
  **Expected behavior**
  JSON is returned like it is now only at https://wiki.developer.mozilla.org/en-US/search.json?q=array
  
  
  **Additional context**
  There might be a few external services, twitter bots etc. that depend on this endpoint.
  
  
  </issue>
  <code>
  [start of kuma/search/views.py]
  1 from django.shortcuts import render
  2 from django.views.decorators.cache import never_cache
  3 from django.views.decorators.http import require_GET
  4 from ratelimit.decorators import ratelimit
  5 
  6 from kuma.api.v1.views import search as search_api
  7 from kuma.core.decorators import shared_cache_control
  8 from kuma.core.utils import is_wiki
  9 
  10 from .search import SearchView
  11 
  12 # Since the search endpoint accepts user input (via query parameters) and its
  13 # response is compressed, use rate limiting to mitigate the BREACH attack
  14 # (see http://breachattack.com/). It still needs to allow a user to click
  15 # the filter switches (bug 1426968).
  16 # Alternate: forbid gzip by setting Content-Encoding: identity
  17 @never_cache
  18 @require_GET
  19 @ratelimit(key='user_or_ip', rate='25/m', block=True)
  20 def search(request, *args, **kwargs):
  21     """
  22     The search view.
  23     """
  24     if is_wiki(request):
  25         return wiki_search(request, *args, **kwargs)
  26 
  27     results = search_api(request, *args, **kwargs).data
  28     context = {
  29         'results': {
  30             'results': None if results.get('error') else results
  31         }
  32     }
  33 
  34     return render(request, 'search/react.html', context)
  35 
  36 
  37 wiki_search = SearchView.as_view()
  38 
  39 
  40 @shared_cache_control(s_maxage=60 * 60 * 24 * 7)
  41 def plugin(request):
  42     """Render an OpenSearch Plugin."""
  43     return render(request, 'search/plugin.html', {
  44         'locale': request.LANGUAGE_CODE
  45     }, content_type='application/opensearchdescription+xml')
  46
  [end of kuma/search/views.py]
  [start of kuma/search/urls.py]
  1 from django.conf.urls import url
  2 from rest_framework.urlpatterns import format_suffix_patterns
  3 
  4 from . import views
  5 
  6 # this allows using ".json" extensions for the view to force json output
  7 lang_base_urlpatterns = format_suffix_patterns(
  8     [url(r'^$', views.search, name='search')])
  9 
  10 
  11 lang_urlpatterns = [
  12     url(r'^xml$',
  13         views.plugin,
  14         name='search.plugin'),
  15 ]
  16
  [end of kuma/search/urls.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/kuma/search/urls.py b/kuma/search/urls.py
  --- a/kuma/search/urls.py
  +++ b/kuma/search/urls.py
  @@ -1,11 +1,11 @@
   from django.conf.urls import url
  -from rest_framework.urlpatterns import format_suffix_patterns
   
   from . import views
   
  -# this allows using ".json" extensions for the view to force json output
  -lang_base_urlpatterns = format_suffix_patterns(
  -    [url(r'^$', views.search, name='search')])
  +lang_base_urlpatterns = [
  +    url(r'^$', views.search, name='search'),
  +    url(r'^.(?P<format>json)$', views.SearchRedirectView.as_view())
  +]
   
   
   lang_urlpatterns = [
  diff --git a/kuma/search/views.py b/kuma/search/views.py
  --- a/kuma/search/views.py
  +++ b/kuma/search/views.py
  @@ -1,6 +1,8 @@
   from django.shortcuts import render
  +from django.urls import reverse_lazy
   from django.views.decorators.cache import never_cache
   from django.views.decorators.http import require_GET
  +from django.views.generic import RedirectView
   from ratelimit.decorators import ratelimit
   
   from kuma.api.v1.views import search as search_api
  @@ -37,6 +39,17 @@
   wiki_search = SearchView.as_view()
   
   
  +class SearchRedirectView(RedirectView):
  +    permanent = True
  +
  +    def get_redirect_url(self, *args, **kwargs):
  +        query_string = self.request.META.get('QUERY_STRING')
  +        url = reverse_lazy('api.v1.search', kwargs={'locale': self.request.LANGUAGE_CODE})
  +        if query_string:
  +            url += '?' + query_string
  +        return url
  +
  +
   @shared_cache_control(s_maxage=60 * 60 * 24 * 7)
   def plugin(request):
       """Render an OpenSearch Plugin."""
  
verification_info: {"golden_diff": "diff --git a/kuma/search/urls.py b/kuma/search/urls.py\n--- a/kuma/search/urls.py\n+++ b/kuma/search/urls.py\n@@ -1,11 +1,11 @@\n from django.conf.urls import url\n-from rest_framework.urlpatterns import format_suffix_patterns\n \n from . import views\n \n-# this allows using \".json\" extensions for the view to force json output\n-lang_base_urlpatterns = format_suffix_patterns(\n-    [url(r'^$', views.search, name='search')])\n+lang_base_urlpatterns = [\n+    url(r'^$', views.search, name='search'),\n+    url(r'^.(?P<format>json)$', views.SearchRedirectView.as_view())\n+]\n \n \n lang_urlpatterns = [\ndiff --git a/kuma/search/views.py b/kuma/search/views.py\n--- a/kuma/search/views.py\n+++ b/kuma/search/views.py\n@@ -1,6 +1,8 @@\n from django.shortcuts import render\n+from django.urls import reverse_lazy\n from django.views.decorators.cache import never_cache\n from django.views.decorators.http import require_GET\n+from django.views.generic import RedirectView\n from ratelimit.decorators import ratelimit\n \n from kuma.api.v1.views import search as search_api\n@@ -37,6 +39,17 @@\n wiki_search = SearchView.as_view()\n \n \n+class SearchRedirectView(RedirectView):\n+    permanent = True\n+\n+    def get_redirect_url(self, *args, **kwargs):\n+        query_string = self.request.META.get('QUERY_STRING')\n+        url = reverse_lazy('api.v1.search', kwargs={'locale': self.request.LANGUAGE_CODE})\n+        if query_string:\n+            url += '?' + query_string\n+        return url\n+\n+\n @shared_cache_control(s_maxage=60 * 60 * 24 * 7)\n def plugin(request):\n     \"\"\"Render an OpenSearch Plugin.\"\"\"\n", "issue": "Search json endpoint is not available in new front-end\n**Summary**\r\nhttps://twitter.com/klaascuvelier/status/1182203293117886464\r\n\r\n\r\n**Steps To Reproduce (STR)**\r\n_How can we reproduce the problem?_\r\n\r\nGo to https://developer.mozilla.org/en-US/search.json?q=array\r\n \r\n\r\n\r\n**Actual behavior**\r\nBlank page\r\n\r\n\r\n**Expected behavior**\r\nJSON is returned like it is now only at https://wiki.developer.mozilla.org/en-US/search.json?q=array\r\n\r\n\r\n**Additional context**\r\nThere might be a few external services, twitter bots etc. that depend on this endpoint.\r\n\n", "before_files": [{"content": "from django.shortcuts import render\nfrom django.views.decorators.cache import never_cache\nfrom django.views.decorators.http import require_GET\nfrom ratelimit.decorators import ratelimit\n\nfrom kuma.api.v1.views import search as search_api\nfrom kuma.core.decorators import shared_cache_control\nfrom kuma.core.utils import is_wiki\n\nfrom .search import SearchView\n\n# Since the search endpoint accepts user input (via query parameters) and its\n# response is compressed, use rate limiting to mitigate the BREACH attack\n# (see http://breachattack.com/). It still needs to allow a user to click\n# the filter switches (bug 1426968).\n# Alternate: forbid gzip by setting Content-Encoding: identity\n@never_cache\n@require_GET\n@ratelimit(key='user_or_ip', rate='25/m', block=True)\ndef search(request, *args, **kwargs):\n    \"\"\"\n    The search view.\n    \"\"\"\n    if is_wiki(request):\n        return wiki_search(request, *args, **kwargs)\n\n    results = search_api(request, *args, **kwargs).data\n    context = {\n        'results': {\n            'results': None if results.get('error') else results\n        }\n    }\n\n    return render(request, 'search/react.html', context)\n\n\nwiki_search = SearchView.as_view()\n\n\n@shared_cache_control(s_maxage=60 * 60 * 24 * 7)\ndef plugin(request):\n    \"\"\"Render an OpenSearch Plugin.\"\"\"\n    return render(request, 'search/plugin.html', {\n        'locale': request.LANGUAGE_CODE\n    }, content_type='application/opensearchdescription+xml')\n", "path": "kuma/search/views.py"}, {"content": "from django.conf.urls import url\nfrom rest_framework.urlpatterns import format_suffix_patterns\n\nfrom . import views\n\n# this allows using \".json\" extensions for the view to force json output\nlang_base_urlpatterns = format_suffix_patterns(\n    [url(r'^$', views.search, name='search')])\n\n\nlang_urlpatterns = [\n    url(r'^xml$',\n        views.plugin,\n        name='search.plugin'),\n]\n", "path": "kuma/search/urls.py"}]}