我有以下端点方法:
public class PlayerEndpoint {
private static final String PLAYER_NAME = "player_name";
private static final String PLAYER_UUID = "player_uuid";
@ApiMethod(name = "register", httpMethod = ApiMethod.HttpMethod.POST, path="register")
public Player register(@Named(PLAYER_UUID) String uuid,
@Named(PLAYER_NAME) String playerName) {
log.info(String.format("Registering user uuid: %s name: %s", uuid, playerName));
...
}
}
当我从我的 Android 客户端调用它时:
String uuid = "test_uuid";
String name = "test_name";
playerEndpoint.register(uuid, name).execute();
后端日志:
Registering user uuid: test_name name: test_uuid
这是怎么回事?
最佳答案
我想通了。显然,Endpoints 按字母顺序对您的方法进行排序。
Method parameters in the generated client library are in alphabetical order, regardless of the original order in the backend method. As a result, you should be careful when editing your methods, especially if there are several parameters of the same type. The compiler will not be able to catch parameter-ordering errors for you.
https://cloud.google.com/developers/articles/google-cloud-endpoints-for-android/
关于android - 为什么 Google Cloud Endpoints 会颠倒我的参数顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30157677/