def process_request(self, request): content = None mode = request.x_mode if mode == MODE_VERSION: content = self.process_mode_version(request) elif mode == MODE_INFO: content = self.process_mode_info(request) elif mode == MODE_SCHEMA: content = self.process_mode_schema(request) else: raise error.ModeNotSupportedError() if not content: if not mode: message = u"Request has not X-Mode" else: message = u"Invalid X-Mode %s" % mode raise error.InternalExceptionError(message) body = simplejson.dumps(content, separators=(",", ":")) response = Response(body=body) response.content_type = "application/json; charset=utf-8" return response
def __call__(self, environ, start_response): response = Response() response.content_type = "text/html" response.encoding = 'utf-8' response.body = "<h1>OK</h1>" #get the controller that handle current XHTTP request controller = environ['xhttp.controller'] return response