def _generate_view(self, method, endpoint):
        """
        Generate a view for the specified method and endpoint.

        :param method: HTTP Method
        :param endpoint: Pattern
        """

        def new_view(**kwargs):
            if method == Method.GET:
                data = request.args
            else:
                content_length = request.headers.get('content-length', 0)
                if content_length and int(content_length) > 0:
                    content_type = request.headers.get('content-type', None)
                    if content_type != 'application/vnd.api+json':
                        data = MissingContentTypeError().data
                        data = json.dumps(data, cls=JSONAPIEncoder)
                        response = make_response(data)
                        response.status_code = 409
                        response.content_type = 'application/vnd.api+json'
                        return response
                    data = request.get_json(force=True)
                else:
                    data = None

            event_kwargs = {
                'method': method,
                'endpoint': endpoint,
                'data': data,
                'req_args': kwargs
            }
            results = self.on_request.send(self, **event_kwargs)
            data = override(data, results)

            args = [self.sqla.session, data, kwargs['api_type']]
            if 'obj_id' in kwargs.keys():
                args.append(kwargs['obj_id'])
            if 'relationship' in kwargs.keys():
                args.append(kwargs['relationship'])

            try:
                attr = '{}_{}'.format(method.name, endpoint.name).lower()
                handler = getattr(self.serializer, attr)
                handler_chain = list(self._handler_chains.get((
                    kwargs['api_type'], method, endpoint), []))
                handler_chain.append(handler)
                chained_handler = self._call_next(handler_chain)
                response = chained_handler(*args)
                results = self.on_success.send(self,
                                               response=response,
                                               **event_kwargs)
                response = override(response, results)
            except BaseError as exc:
                self.sqla.session.rollback()
                results = self.on_error.send(self, error=exc, **event_kwargs)
                response = override(exc, results)
            rendered_response = make_response('')
            if response.status_code != 204:
                data = json.dumps(response.data, cls=self.json_encoder)
                rendered_response = make_response(data)
            rendered_response.status_code = response.status_code
            rendered_response.content_type = 'application/vnd.api+json'
            results = self.on_response.send(self,
                                            response=rendered_response,
                                            **event_kwargs)
            return override(rendered_response, results)

        return new_view
Generate a view for the specified method and endpoint.

        :param method: HTTP Method
        :param endpoint: Pattern