本文整理了Java中retrofit2.Retrofit.baseUrl
方法的一些代码示例,展示了Retrofit.baseUrl
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Retrofit.baseUrl
方法的具体详情如下:
包路径:retrofit2.Retrofit
类名称:Retrofit
方法名:baseUrl
[英]The API base URL.
[中]API基本URL。
代码示例来源:origin: line/armeria
@Test
public void build_armeriaGroupAuthority() throws Exception {
assertThat(new ArmeriaRetrofitBuilder().baseUrl("http://group:myGroup/").build().baseUrl()
.toString())
// NB: lower-cased by OkHttp
.isEqualTo("http://group_mygroup/");
assertThat(new ArmeriaRetrofitBuilder().baseUrl("http://group:myGroup").build().baseUrl()
.toString())
.isEqualTo("http://group_mygroup/");
}
}
代码示例来源:origin: line/armeria
@Test
public void build() throws Exception {
final Retrofit retrofit = new ArmeriaRetrofitBuilder().baseUrl("http://example.com:8080/").build();
assertThat(retrofit.baseUrl().toString()).isEqualTo("http://example.com:8080/");
}
代码示例来源:origin: line/armeria
@Test
public void build_withoutSlashAtEnd() throws Exception {
final Retrofit retrofit = new ArmeriaRetrofitBuilder().baseUrl("http://example.com:8080").build();
assertThat(retrofit.baseUrl().toString()).isEqualTo("http://example.com:8080/");
}
代码示例来源:origin: line/armeria
@Test
public void build_withNonRootPath() throws Exception {
assertThat(new ArmeriaRetrofitBuilder().baseUrl("http://example.com:8080/a/b/c/")
.build().baseUrl().toString())
.isEqualTo("http://example.com:8080/a/b/c/");
}
代码示例来源:origin: line/armeria
@Test
public void build_moreSessionProtocol() throws Exception {
assertThat(new ArmeriaRetrofitBuilder().baseUrl("h1c://example.com:8080/").build().baseUrl()
.toString())
.isEqualTo("http://example.com:8080/");
assertThat(new ArmeriaRetrofitBuilder().baseUrl("h2c://example.com:8080/").build().baseUrl()
.toString())
.isEqualTo("http://example.com:8080/");
assertThat(new ArmeriaRetrofitBuilder().baseUrl("h1://example.com:8080/").build().baseUrl()
.toString())
.isEqualTo("https://example.com:8080/");
assertThat(new ArmeriaRetrofitBuilder().baseUrl("h2://example.com:8080/").build().baseUrl()
.toString())
.isEqualTo("https://example.com:8080/");
assertThat(new ArmeriaRetrofitBuilder().baseUrl("https://example.com:8080/").build().baseUrl()
.toString())
.isEqualTo("https://example.com:8080/");
}
代码示例来源:origin: DroidsOnRoids/jspoon
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
try {
return new JspoonResponseBodyConverter<>(retrofit.baseUrl(),
jspoon.adapter((Class<?>) type));
} catch (EmptySelectorException ex) {
return null; // Let retrofit choose another converter
}
}
}
代码示例来源:origin: pl.droidsonroids.retrofit2/converter-jspoon
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
try {
return new JspoonResponseBodyConverter<>(retrofit.baseUrl(),
jspoon.adapter((Class<?>) type));
} catch (EmptySelectorException ex) {
return null; // Let retrofit choose another converter
}
}
}
代码示例来源:origin: org.nuxeo.client/nuxeo-java-client
/**
* This method gets the Nuxeo server version from CMIS the first time and then caches it.
*
* @return The Nuxeo server version.
*/
public NuxeoVersion getServerVersion() {
if (serverVersion == null) {
try {
// Remove API_PATH from the base url
// Get repository capabilities on CMIS
Response response = get(
retrofit.baseUrl().toString().replaceFirst(ConstantsV1.API_PATH, "") + "/json/cmis");
String body = response.body().string();
Matcher matcher = CMIS_PRODUCT_VERSION_PATTERN.matcher(body);
if (matcher.find()) {
String version = matcher.group(1);
serverVersion = NuxeoVersion.parse(version);
} else {
throw new NuxeoClientException("Unable to get version from CMIS");
}
} catch (IOException ioe) {
throw new NuxeoClientException("Unable to retrieve the server version.", ioe);
}
}
return serverVersion;
}
代码示例来源:origin: NightscoutFoundation/xDrip
doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed
doRESTUploadTo(nightscoutService, hashedSecret, glucoseDataSets, meterRecords, calRecords);
} else {
代码示例来源:origin: jamorham/xDrip-plus
doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed
doRESTUploadTo(nightscoutService, hashedSecret, glucoseDataSets, meterRecords, calRecords);
} else {
代码示例来源:origin: Azure/azure-libraries-for-java
/**
* Try to extract the environment the client is authenticated to based
* on the information on the rest client.
* @param restClient the RestClient instance
* @return the non-null AzureEnvironment
*/
public static AzureEnvironment extractAzureEnvironment(RestClient restClient) {
AzureEnvironment environment = null;
if (restClient.credentials() instanceof AzureTokenCredentials) {
environment = ((AzureTokenCredentials) restClient.credentials()).environment();
} else {
String baseUrl = restClient.retrofit().baseUrl().toString();
for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) {
if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) {
environment = env;
break;
}
}
if (environment == null) {
throw new IllegalArgumentException("Unknown resource manager endpoint " + baseUrl);
}
}
return environment;
}
代码示例来源:origin: com.microsoft.azure/azure-mgmt-resources
/**
* Try to extract the environment the client is authenticated to based
* on the information on the rest client.
* @param restClient the RestClient instance
* @return the non-null AzureEnvironment
*/
public static AzureEnvironment extractAzureEnvironment(RestClient restClient) {
AzureEnvironment environment = null;
if (restClient.credentials() instanceof AzureTokenCredentials) {
environment = ((AzureTokenCredentials) restClient.credentials()).environment();
} else {
String baseUrl = restClient.retrofit().baseUrl().toString();
for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) {
if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) {
environment = env;
break;
}
}
if (environment == null) {
throw new IllegalArgumentException("Unknown resource manager endpoint " + baseUrl);
}
}
return environment;
}
代码示例来源:origin: Azure/azure-libraries-for-java
@Override
public ActiveDirectoryGroupImpl withMember(String objectId) {
membersToAdd.add(String.format("https://%s/%s/directoryObjects/%s",
manager().inner().retrofit().baseUrl().host(), manager().tenantId(), objectId));
return this;
}
代码示例来源:origin: lygttpod/RxHttpUtils
singleRetrofitBuilder.baseUrl(RetrofitClient.getInstance().getRetrofit().baseUrl());
} else {
singleRetrofitBuilder.baseUrl(baseUrl);
代码示例来源:origin: Azure/azure-libraries-for-java
AzureEnvironment environment() {
RestClient restClient = this.manager().inner().restClient();
AzureEnvironment environment = null;
if (restClient.credentials() instanceof AzureTokenCredentials) {
environment = ((AzureTokenCredentials) restClient.credentials()).environment();
}
String baseUrl = restClient.retrofit().baseUrl().toString();
for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) {
if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) {
environment = env;
break;
}
}
if (environment != null) {
return environment;
}
throw new IllegalArgumentException("Unknown environment");
}
代码示例来源:origin: com.microsoft.azure/azure-mgmt-compute
AzureEnvironment environment() {
RestClient restClient = this.manager().inner().restClient();
AzureEnvironment environment = null;
if (restClient.credentials() instanceof AzureTokenCredentials) {
environment = ((AzureTokenCredentials) restClient.credentials()).environment();
}
String baseUrl = restClient.retrofit().baseUrl().toString();
for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) {
if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) {
environment = env;
break;
}
}
if (environment != null) {
return environment;
}
throw new IllegalArgumentException("Unknown environment");
}
代码示例来源:origin: jamorham/xDrip-plus
final NightscoutService nightscoutService = retrofit.create(NightscoutService.class);
final String checkurl = retrofit.baseUrl().url().toString();
if (!isNightscoutCompatible(checkurl)) {
Log.e(TAG, "Nightscout version: " + getNightscoutVersion(checkurl) + " on " + checkurl + " is not compatible with the Rest-API download feature!");
final Response<ResponseBody> r;
if (hashedSecret != null) {
doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed
final String LAST_MODIFIED_KEY = LAST_SUCCESS_TREATMENT_DOWNLOAD + CipherUtils.getMD5(uri.toString()); // per uri marker
String last_modified_string = PersistentStore.getString(LAST_MODIFIED_KEY);
代码示例来源:origin: com.microsoft.rest/client-runtime
this.httpClientBuilder.interceptors().clear();
this.httpClientBuilder.networkInterceptors().clear();
this.baseUrl = restClient.retrofit.baseUrl().toString();
this.responseBuilderFactory = restClient.builder.responseBuilderFactory;
this.serializerAdapter = restClient.builder.serializerAdapter;
代码示例来源:origin: NightscoutFoundation/xDrip
final NightscoutService nightscoutService = retrofit.create(NightscoutService.class);
final String checkurl = retrofit.baseUrl().url().toString();
if (!isNightscoutCompatible(checkurl)) {
Log.e(TAG, "Nightscout version: " + getNightscoutVersion(checkurl) + " on " + checkurl + " is not compatible with the Rest-API download feature!");
final Response<ResponseBody> r;
if (hashedSecret != null) {
doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed
final String LAST_MODIFIED_KEY = LAST_SUCCESS_TREATMENT_DOWNLOAD + CipherUtils.getMD5(uri.toString()); // per uri marker
String last_modified_string = PersistentStore.getString(LAST_MODIFIED_KEY);
内容来源于网络,如有侵权,请联系作者删除!