https://github.com/fengzhizi715/okhttp-extension
okhttp-extension 是针对 okhttp 3 增强的网络框架。使用 Kotlin 特性编写,提供便捷的 DSL 方式创建网络请求,支持协程、响应式编程等等。
https://github.com/fengzhizi715/okhttp-extension
coroutines dsl feign flow interceptor kotlin okhttp3 resilience4j retrofit2 rxjava stomp websocket
Last synced: 6 months ago
JSON representation
okhttp-extension 是针对 okhttp 3 增强的网络框架。使用 Kotlin 特性编写,提供便捷的 DSL 方式创建网络请求,支持协程、响应式编程等等。
- Host: GitHub
- URL: https://github.com/fengzhizi715/okhttp-extension
- Owner: fengzhizi715
- License: apache-2.0
- Created: 2020-09-11T15:53:47.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-15T11:15:14.000Z (over 2 years ago)
- Last Synced: 2025-04-01T10:41:52.927Z (7 months ago)
- Topics: coroutines, dsl, feign, flow, interceptor, kotlin, okhttp3, resilience4j, retrofit2, rxjava, stomp, websocket
- Language: Kotlin
- Homepage:
- Size: 1.72 MB
- Stars: 44
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://www.weibo.com/fengzhizi715)
[](https://www.apache.org/licenses/LICENSE-2.0.html)
[](https://jitpack.io/#fengzhizi715/okhttp-extension)# okhttp-extension
okhttp-extension 是针对 okhttp 3 增强的网络框架。使用 Kotlin 特性编写,提供便捷的 DSL 方式创建网络请求,支持协程、响应式编程等等。
其中 core 模块只依赖 OkHttp,不会引入第三方库。
okhttp-extension 可以整合 Retrofit、Feign 框架,还提供了很多常用的拦截器,以及非常多的特性。 okhttp-extension 也给开发者提供一种新的选择。
## Features:
* 支持 DSL 创建 HTTP `GET`/`POST`/`PUT`/`HEAD`/`DELETE`/`PATCH` requests.
* 支持文件上传/下载
* 支持 Kotlin 协程
* 支持响应式(RxJava、Spring Reactor)
* 支持函数式
* 支持熔断器(Resilience4j)
* 支持异步请求的取消
* 支持预连接
* 支持 Request、Response 的拦截器
* 提供多款常用的拦截器
* 支持自定义线程池
* 支持整合 Retrofit、Feign 框架
* 支持 WebSocket 的实现、自动重连等
* 支持 Stomp over WebSocket
* core 模块只依赖 OkHttp,不依赖其他第三方库## 更详细的功能请查看 [wiki](https://github.com/fengzhizi715/okhttp-extension/wiki)

## 最新版本
模块|最新版本
---|:-------------:
core|[](https://jitpack.io/#fengzhizi715/okhttp-extension)|
coroutines|[](https://jitpack.io/#fengzhizi715/okhttp-extension)|
rxjava3|[](https://jitpack.io/#fengzhizi715/okhttp-extension)|
rxjava2|[](https://jitpack.io/#fengzhizi715/okhttp-extension)|
reactor|[](https://jitpack.io/#fengzhizi715/okhttp-extension)|
result|[](https://jitpack.io/#fengzhizi715/okhttp-extension)|
resilience4j|[](https://jitpack.io/#fengzhizi715/okhttp-extension)|## 下载
将它添加到项目的 root build.gradle 中:
```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```其余,按需依赖各个模块,其中 core 是必须要依赖的
```groovy
implementation 'com.github.fengzhizi715.okhttp-extension:core:'
``````groovy
implementation 'com.github.fengzhizi715.okhttp-extension:coroutines:'
``````groovy
implementation 'com.github.fengzhizi715.okhttp-extension:rxjava3:'
``````groovy
implementation 'com.github.fengzhizi715.okhttp-extension:rxjava2:'
``````groovy
implementation 'com.github.fengzhizi715.okhttp-extension:reactor:'
``````groovy
implementation 'com.github.fengzhizi715.okhttp-extension:result:'
``````groovy
implementation 'com.github.fengzhizi715.okhttp-extension:resilience4j:'
```## 感谢
* 参考了 [http4k](https://github.com/http4k/http4k) 的实现
* 参考了 [kohttp](https://github.com/rybalkinsd/kohttp) 的实现
* 参考了 [kotlin-stomp-client](https://github.com/DinuBerinde/kotlin-stomp-client) 的实现## TODO List:
* 完善文档
* 完善和 Spring/Springboot 集成以及相关示例
* 支持 kotlinx-serialization
* 异常的日志记录
* 支持 Micrometer## ChangeLog
[ChangeLog](CHANGELOG.md)