def _dispatch(self, operation, request, path_args):
        """
        Wrapped dispatch method, prepare request and generate a HTTP Response.
        """
        # Determine the request and response types. Ensure API supports the requested types
        request_type = resolve_content_type(self.request_type_resolvers, request)
        request_type = self.remap_codecs.get(request_type, request_type)
        try:
            request.request_codec = self.registered_codecs[request_type]
        except KeyError:
            return HttpResponse.from_status(HTTPStatus.UNPROCESSABLE_ENTITY)

        response_type = resolve_content_type(self.response_type_resolvers, request)
        response_type = self.remap_codecs.get(response_type, response_type)
        try:
            request.response_codec = self.registered_codecs[response_type]
        except KeyError:
            return HttpResponse.from_status(HTTPStatus.NOT_ACCEPTABLE)

        # Check if method is in our allowed method list
        if request.method not in operation.methods:
            return HttpResponse.from_status(
                HTTPStatus.METHOD_NOT_ALLOWED,
                {'Allow': ','.join(m.value for m in operation.methods)}
            )

        # Response types
        resource, status, headers = self.dispatch_operation(operation, request, path_args)

        if isinstance(status, HTTPStatus):
            status = status.value

        # Return a HttpResponse and just send it!
        if isinstance(resource, HttpResponse):
            return resource

        # Encode the response
        return create_response(request, resource, status, headers)
def _dispatch ( self , operation , request , path_args ) : request_type = resolve_content_type ( self . request_type_resolvers , request ) request_type = self . remap_codecs . get ( request_type , request_type ) try : request . request_codec = self . registered_codecs [ request_type ] except KeyError : return HttpResponse . from_status ( HTTPStatus . UNPROCESSABLE_ENTITY ) response_type = resolve_content_type ( self . response_type_resolvers , request ) response_type = self . remap_codecs . get ( response_type , response_type ) try : request . response_codec = self . registered_codecs [ response_type ] except KeyError : return HttpResponse . from_status ( HTTPStatus . NOT_ACCEPTABLE ) if request . method not in operation . methods : return HttpResponse . from_status ( HTTPStatus . METHOD_NOT_ALLOWED , { 'Allow' : ',' . join ( m . value for m in operation . methods ) } ) resource , status , headers = self . dispatch_operation ( operation , request , path_args ) if isinstance ( status , HTTPStatus ) : status = status . value if isinstance ( resource , HttpResponse ) : return resource return create_response ( request , resource , status , headers )
Wrapped dispatch method, prepare request and generate a HTTP Response.