code: def set_config_for_routing_entity(
              self,
              routing_entity: Union[web.Resource, web.StaticResource,
                                    web.ResourceRoute],
              config):
          
  
          if isinstance(routing_entity, (web.Resource, web.StaticResource)):
              resource = routing_entity
  
              # Add resource configuration or fail if it's already added.
              if resource in self._resource_config:
                  raise ValueError(
                      "CORS is already configured for {!r} resource.".format(
                          resource))
  
              self._resource_config[resource] = _ResourceConfig(
                  default_config=config)
  
          elif isinstance(routing_entity, web.ResourceRoute):
              route = routing_entity
  
              # Add resource's route configuration or fail if it's already added.
              if route.resource not in self._resource_config:
                  self.set_config_for_routing_entity(route.resource, config)
  
              if route.resource not in self._resource_config:
                  raise ValueError(
                      "Can't setup CORS for {!r} request, "
                      "CORS must be enabled for route's resource first.".format(
                          route))
  
              resource_config = self._resource_config[route.resource]
  
              if route.method in resource_config.method_config:
                  raise ValueError(
                      "Can't setup CORS for {!r} route: CORS already "
                      "configured on resource {!r} for {} method".format(
                          route, route.resource, route.method))
  
              resource_config.method_config[route.method] = config
  
          else:
              raise ValueError(
                  "Resource or ResourceRoute expected, got {!r}".format(
                      routing_entity))
docs: Record configuration for resource or it's route.