Skip to content

Commit

Permalink
doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
chentianming11 committed Jul 4, 2022
1 parent 7e20de8 commit dc048be
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 39 deletions.
41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,32 @@ retrofit:
@Slf4j
@Component
public class CustomSourceOkHttpClientRegistrar implements SourceOkHttpClientRegistrar {
@Override
public void register(SourceOkHttpClientRegistry registry) {
// 替换默认的SourceOkHttpClient
registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, new OkHttpClient.Builder()
.addInterceptor(chain -> {
log.info("============替换默认的SourceOkHttpClient=============");
@Override
public void register(SourceOkHttpClientRegistry registry) {
// 替换默认的SourceOkHttpClient,可以用来修改全局OkhttpClient设置
registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(5))
.writeTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.addInterceptor(chain -> {
log.info("============replace default SourceOkHttpClient=============");
return chain.proceed(chain.request());
})
.build());
// 添加新的SourceOkHttpClient
registry.register("testSourceOkHttpClient", new OkHttpClient.Builder()
.addInterceptor(chain -> {
log.info("============使用testSourceOkHttpClient=============");
})
.build());
// 添加testSourceOkHttpClient
registry.register("testSourceOkHttpClient", new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(3))
.writeTimeout(Duration.ofSeconds(3))
.readTimeout(Duration.ofSeconds(3))
.addInterceptor(chain -> {
log.info("============use testSourceOkHttpClient=============");
return chain.proceed(chain.request());
})
.build());
}
})
.build());
}
}
```

Expand Down
39 changes: 24 additions & 15 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,32 @@ retrofit:
@Slf4j
@Component
public class CustomSourceOkHttpClientRegistrar implements SourceOkHttpClientRegistrar {
@Override
public void register(SourceOkHttpClientRegistry registry) {
registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, new OkHttpClient.Builder()
.addInterceptor(chain -> {
log.info("============Replace the default SourceOkHttpClient=============");
@Override
public void register(SourceOkHttpClientRegistry registry) {
// replace default SourceOkHttpClient. Can be used to modify global `Okhttp Client` settings
registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(5))
.writeTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.addInterceptor(chain -> {
log.info("============replace default SourceOkHttpClient=============");
return chain.proceed(chain.request());
})
.build());
registry.register("testSourceOkHttpClient", new OkHttpClient.Builder()
.addInterceptor(chain -> {
log.info("============testSourceOkHttpClient=============");
})
.build());

// add testSourceOkHttpClient
registry.register("testSourceOkHttpClient", new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(3))
.writeTimeout(Duration.ofSeconds(3))
.readTimeout(Duration.ofSeconds(3))
.addInterceptor(chain -> {
log.info("============use testSourceOkHttpClient=============");
return chain.proceed(chain.request());
})
.build());
}
})
.build());
}
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ public class CustomSourceOkHttpClientRegistrar implements SourceOkHttpClientRegi
@Override
public void register(SourceOkHttpClientRegistry registry) {

// 替换默认的SourceOkHttpClient
// 替换默认的SourceOkHttpClient,可以用来修改全局OkhttpClient设置
registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(5))
.writeTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.addInterceptor(chain -> {
log.info("============替换默认的SourceOkHttpClient=============");
log.info("============replace default SourceOkHttpClient=============");
return chain.proceed(chain.request());
})
.build());

// 添加新的SourceOkHttpClient
// 添加testSourceOkHttpClient
registry.register("testSourceOkHttpClient", new OkHttpClient.Builder()
.connectTimeout(Duration.ofSeconds(5))
.writeTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.connectTimeout(Duration.ofSeconds(3))
.writeTimeout(Duration.ofSeconds(3))
.readTimeout(Duration.ofSeconds(3))
.addInterceptor(chain -> {
log.info("============使用testSourceOkHttpClient=============");
log.info("============use testSourceOkHttpClient=============");
return chain.proceed(chain.request());
})
.build());
Expand Down

0 comments on commit dc048be

Please sign in to comment.