正如标题所说,是否有一种方法可以同时向JSON-RPC和XML-RPC接口公开函数?最好是在一个端口上运行的一个服务器可以回答这两种类型的请求。
谢谢!
返回不同格式的常用方法之一是以某种方式在url中指定您想要的类型。最常见的是:
http://example.com/some/page.<format>
或
http://example.com/some/page?output=<format>
然后将返回的对象转换为所需的格式:
// somewhere at the end of the method handling the request
return Formater(format_param).format(response_object)