code: def as_view(cls, endpoint, protocol, *init_args, **init_kwargs):
          '''
          Used for hooking up the endpoints. Returns a wrapper function that creates
          a new instance of the resource class and calls the correct view method for it.
          '''
          def _wrapper(request, *args, **kwargs):
              ''' Make a new instance of the resource class and returns a coroutine for execution'''
              instance = cls(*init_args, endpoint=endpoint, request=request, **init_kwargs)
              if protocol == Resource.Protocol.http:
                  return instance._wrap_http(cls.dispatch, endpoint=endpoint, *args, **kwargs)
              elif protocol == Resource.Protocol.websocket:
                  return instance._wrap_ws(cls.dispatch, endpoint=endpoint, *args, **kwargs)
              elif protocol == Resource.Protocol.amqp:
                  return instance._wrap_amqp(endpoint, *args, **kwargs)
              else:
                  raise Exception('Communication protocol not specified')
  
          return _wrappef as_view(cls, endpoint, protocol, *init_args, **init_kwargs):
          '''
          Used for hooking up the endpoints. Returns a wrapper function that creates
          a new instance of the resource class and calls the correct view method for it.
          '''
          def _wrapper(request, *args, **kwargs):
              ''' Make a new instance of the resource class and returns a coroutine for execution'''
              instance = cls(*init_args, endpoint=endpoint, request=request, **init_kwargs)
              if protocol == Resource.Protocol.http:
                  return instance._wrap_http(cls.dispatch, endpoint=endpoint, *args, **kwargs)
              elif protocol == Resource.Protocol.websocket:
                  return instance._wrap_ws(cls.dispatch, endpoint=endpoint, *args, **kwargs)
              elif protocol == Resource.Protocol.amqp:
                  return instance._wrap_amqp(endpoint, *args, **kwargs)
              else:
                  raise Exception('Communication protocol not specified')
  
          return _wrapper
docs: Used for hooking up the endpoints. Returns a wrapper function that creates
          a new instance of the resource class and calls the correct view method for it.