from aiohttp import web

from brink.serialization import json_dumps
from brink.exceptions import HTTPBadRequest


class WebSocketResponse(web.WebSocketResponse):

    def send_json(self, json, *args, **kwargs):
        super().send_json(json, *args, dumps=json_dumps, **kwargs)


def __handler_wrapper(handler):
    async def new_handler(request):
        status, data = await handler(request)
        return web.json_response(data, status=status, dumps=json_dumps)
    return new_handler


def __ws_handler_wrapper(handler):
    async def new_handler(request):
        ws = WebSocketResponse()
        await ws.prepare(request)
        await handler(request, ws)
        return ws
    return new_handler

@@ -1,12 +1,40 @@
+import importlib%0Aimport re%0A%0A
 from aiohttp
@@ -133,16 +133,48 @@
 Request%0A
+from brink.config import config%0A
 %0A%0Aclass 
@@ -735,16 +735,16 @@
 turn ws%0A
-
     retu
@@ -738,28 +738,629 @@
 n ws%0A    return new_handler%0A
+%0A%0Adef __get_url_params(url):%0A    return re.findall(r%22%7B(.*?)%7D%22, url)%0A%0A%0Aasync def handle_list_urls(request):%0A    apps = config.get(%22INSTALLED_APPS%22, default=%5B%5D)%0A    endpoints = %5B%5D%0A%0A    for app in apps:%0A        try:%0A            urls = importlib.import_module(%22%25s.urls%22 %25 app)%0A%0A            for (method, url, _) in urls.urls:%0A                endpoints.append(%7B%0A                    %22method%22: method,%0A                    %22url%22: url,%0A                    %22url_params%22: __get_url_params(url),%0A                %7D)%0A        except ModuleNotFoundError as e:%0A            continue%0A%0A    return 200, %7B%22data%22: endpoints%7D%0A

Add handle_list_urls handler