问题描述
我想知道如何创建一个可以在两个端点之间切换的 RestAdapter.目前在我的应用程序中,RestAdapter 是在 Application 类(单例)中创建的.我正在寻找一种方法来拥有不同的端点,而无需实际创建多个 RestAdapter.
I would like to know how to create a RestAdapter that can switch between two endpoints. Currently in my app, the RestAdapter is created in the Application class(singleton). I am looking for a way to have different endpoints without actually creating multiple RestAdapter.
推荐答案
Endpoint 为每个请求调用.如果你想打开一个算法,你可以实现你自己的(例如,做循环).除此之外,单个 RestAdapter 与 Endpoint 相关联,您无法在每个方法或任何方法的基础上控制它.- 杰克沃顿
Endpoint is called for every request. If you want to switch on an algorithm you can implement your own (e.g., to do round-robin). Other than that, a single RestAdapter is tied to an Endpoint, you cannot control it on a per-method basis or anything. - Jake Wharton
因此,我为应用中使用的不同端点创建了不同的 rest 适配器.
So I created different rest adapters for the different endpoints I use in my app.
这篇关于改造 - 具有相同 RestAdapter 的多个端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!