def _resolve_request(self, url_path, format):
        # custom provider
        if self.application.custom_provider is not None:
            response = self.application.custom_provider(self.request)
            if response is not None:
                return self._write_response(response)

        # get request data
        self.format = self._get_format(format)
        method = self.request.method
        self.status_code = int(self.get_argument("__statusCode", 200))

        # upstream server
        upstream_server = self.api_data.get_upstream_server(
            "%s-%s" % (method, url_path))

        if self.api_data.upstream_server and upstream_server:
            return self._handle_request_on_upstream()

        # mock
        provider = rest.FilesMockProvider(self.api_dir)

        response = rest.resolve_request(
            provider, method, url_path, self.status_code, self.format)

        if provider.error:
            if self.api_data.upstream_server:
                return self._handle_request_on_upstream()

        # set content type
        already_content_type = [
            item[0] for item in response.headers
            if item[0] == 'Content-Type']
        if not already_content_type:
            content_type = SUPPORTED_FORMATS[self.format][0]
            response.headers.append(
                ("Content-Type", "%s; charset=utf-8" % content_type))
        response.headers.append(
            ("Access-Control-Allow-Origin", "*"))

        # log request
        self.log_request(response)

        # response
        try:
            self.set_status(response.status_code)
        except __HOLE__:
            self._reason = 'Custom status code'

        self.set_headers(response.headers)

        self.write(response.content)
        self.finish()
dataset/ETHPy150Open tomashanacek/mock-server/mock_server/handlers.py/MainHandler._resolve_request