2
我有以下方法來獲取我的端點實例。我想添加一個頭到它。我怎麼做?請修改我的代碼,以包含標題位。謝謝。將標題添加到Google Cloud Endpoint中Android
public class RemoteServiceEndpointReference {
private static final boolean USING_LOCAL_SERVER = false;
private static final String LOCAL_SERVER_PATH = 「…」;
private static RemoteService service;
public static RemoteService getRemoteServiceEndpoint() {
if (null != service) {
return service;
}
RemoteService.Builder builder = new RemoteService.Builder(
AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(),
null
);
forLocalServer(builder);
service = builder.build();
return service;
}
private static void forLocalServer(AbstractGoogleJsonClient.Builder builder) {
if (USING_LOCAL_SERVER) {
builder.setRootUrl(LOCAL_SERVER_PATH)
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
request.setDisableGZipContent(true);
}
});
}
}
}