def register(self, router: UrlDispatcher): router.add_route( '*', '/{notes}'.format(notes=self.notes), self.collection_endpoint.dispatch ) router.add_route( '*', '/{notes}/{{instance_id}}'.format(notes=self.articles), self.instance_endpoint.dispatch )
def change_routes(self, routes): router = UrlDispatcher() try: for route in routes: router.add_route(route.method, route.path, route.handler, name=route.id) except Exception as exc: raise InvalidRouteError("Invalid route") from exc else: self._router = router if self._frozen: self._router.freeze()
def register_routes(self, router: UrlDispatcher, version_prefix: Optional[str] = None): """ :param router: :param version_prefix: :return: """ for route in self.produce_routes(version_prefix): try: router.add_route('*', route, self.dispatch) if logging.getLogger().getEffectiveLevel() == logging.DEBUG: logging.info('{0} is connected {1}'.format( self.__class__, route)) except RuntimeError as e: raise RuntimeError( 'Seems URL {0}, described in {1}, is already connected to another endpoint' .format(route, self.__class__))
def register(self, router: UrlDispatcher): router.add_route('*', '/employees'.format(employees=self.employees), self.employee_endpoint.dispatch) router.add_route('*', '/cars'.format(cars=self.cars), self.car_endpoint.dispatch) router.add_route('*', '/parts'.format(parts=self.parts), self.part_endpoint.dispatch)
def route(self, router: UrlDispatcher): router.add_route("POST", "/users:search", self.search_users) router.add_route("POST", "/token/email_verify", self.generate_email_verifying_token) router.add_route("POST", "/token/password_reset", self.generate_password_reset_token)
def register(self, router: UrlDispatcher): router.add_route('*', '/', self.collection_endpoint.dispatch) router.add_route('*', f'/{self.news}/{{id}}', self.instance_endpoint.dispatch)
def register(self, router: UrlDispatcher): router.add_route('*', '/posts', self.collection_view.dispatch) router.add_route('*', '/posts/{instance_id}', self.instance_view.dispatch)
def register(self, router: UrlDispatcher): router.add_route('*', '/{notes}'.format(notes=self.notes), self.collection_endpoint.dispatch)
def register(self, router: UrlDispatcher): router.add_route('*', '/{collection}'.format(collection=self.collection_name), self.collection_endpoint.dispatch) router.add_route('*', '/{collection}/{{instance_id}}'.format(collection=self.collection_name), self.instance_endpoint.dispatch)
def route(self, router: UrlDispatcher): router.add_route("POST", "/email", self.create_email_user) router.add_route("POST", "/third_party", self.create_third_party_user) router.add_route("GET", "/-/self", self.get_myself) router.add_route("PUT", "/-/self", self.update_myself) router.add_route("GET", "/-/{user_id}", self.get_user) router.add_route("POST", "/-/self:verify", self.verify_myself) router.add_route("PUT", "/email/self/password", self.update_email_user_password) router.add_route("POST", "/email/self/password:reset", self.reset_email_user_password)
import asyncio import pytest from aiohttp import web from aiohttp.web_urldispatcher import UrlDispatcher @asyncio.coroutine def hello(request): return web.Response(body=b'Hello World') router = UrlDispatcher() router.add_route('GET', '/', hello) class TestPrerequisities: @pytest.mark.asyncio def test_server(self, connection, mock_url): response = yield from connection._session.get(mock_url) assert response.status == 200 assert (yield from response.read()) == b'Hello World'
return web.Response(status=401) # Get blob try: blob = _blobs[blob_id] except KeyError: return web.Response(status=404) else: return web.Response( body=blob, content_type='application/octet-stream' ) router = UrlDispatcher() router.add_route('GET', '/pubkeys/{key}', pubkeys) router.add_route('GET', '/lookup/phone/{phone}', lookup_phone) router.add_route('GET', '/lookup/phone_hash/{phone_hash}', lookup_phone_hash) router.add_route('GET', '/lookup/email/{email}', lookup_email) router.add_route('GET', '/lookup/email_hash/{email_hash}', lookup_email_hash) router.add_route('GET', '/capabilities/{id}', capabilities) router.add_route('GET', '/credits', credits) router.add_route('POST', '/send_simple', send_simple) router.add_route('POST', '/send_e2e', send_e2e) router.add_route('POST', '/upload_blob', upload_blob) router.add_route('GET', '/blobs/{blob_id}', download_blob) class RawMessage(e2e.Message): def __init__(self, nonce=None, message=None, **kwargs): super().__init__(e2e.Message.Type.text_message, **kwargs)
def register(self, router: UrlDispatcher): router.add_route('*', '/{users}/{{instance_id}}'.format(users=self.users), self.instance_endpoint.dispatch)
def route(self, router: UrlDispatcher): router.add_route("PUT", "", self.put) router.add_route("POST", "/third_party", self.create_third_party_user_token) router.add_route("POST", "/email", self.create_email_user_token) router.add_route("GET", "/self", self.get)
def register(self, router: UrlDispatcher): router.add_route('*', '/{name}'.format(name=self.name), self.collection_endpoint.dispatch) router.add_route('*', '/{name}/{{instance_id}}'.format(name=self.name), self.instance_endpoint.dispatch) router.add_route('*', '/{name}/{{instance_id}}/{{property_name}}'.format(name=self.name), self.property_endpoint.dispatch)