https://github.com/limuyang2/msnet
π A type-safe HTTP client for Android, based on okcronet
https://github.com/limuyang2/msnet
Last synced: about 2 months ago
JSON representation
π A type-safe HTTP client for Android, based on okcronet
- Host: GitHub
- URL: https://github.com/limuyang2/msnet
- Owner: limuyang2
- License: mit
- Created: 2024-03-27T07:07:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-18T15:46:36.000Z (5 months ago)
- Last Synced: 2025-02-03T22:28:19.147Z (4 months ago)
- Language: Java
- Homepage:
- Size: 204 KB
- Stars: 27
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# msnet
A type-safe HTTP client for Android, based on okcronet.Similar to Retrofit, this is a wrapper for [okcronet](https://github.com/limuyang2/okcronet). Usage is consistent with Retrofit.
Even low-cost migration can be achieved by simply replacing the corresponding "import" reference.
[δΈζ](https://github.com/limuyang2/msnet/blob/main/README_CN.md)
# Advantages of msnet
* Extensibility: msnet allows you to extend its functionality using interceptors implemented with OkCronet, such as adding new protocol support or customizing network behavior.
* Completeness: msnet provides a complete HTTP3/QUIC solution, including support for QUIC connection migration.
* Ease of use: msnet's usage is consistent with Retrofit, making it easy for developers to migrate.# Import
## Importing the library
```
implementation("io.github.limuyang2:msnet:1.0.2")
```## Importing the Cronet library
### Recommended method for mainland China(Contains complete local `so` library):
```
implementation("org.chromium.net:cronet-api:119.6045.31")
implementation("org.chromium.net:cronet-common:119.6045.31")
implementation("org.chromium.net:cronet-embedded:119.6045.31")
```
### Method for using Google Play overseas:
Reference link - [android develop](https://developer.android.com/develop/connectivity/cronet/start#kts)
```
implementation("com.google.android.gms:play-services-cronet:18.0.1")
```# Using
* Create interface
```kotlin
interface Api {@GET("lishi/api.php")
fun todayCall(): Call@GET("lishi/api.php")
@DisableCache
suspend fun todayResponse(): Response
}
```* Make a request
```kotlin
// Create CronetClient
val cronetClient = CronetClient.Builder(cronetEngine).build()// Create msnet
val msnet = MSNet.Builder()
.cronet(cronetClient)
.baseUrl("https://api.oick.cn/")
.build()// Get interface
val api = msnet.create()// Request network to get results
val response = api.todayResponse()// Output results
println("Result: ${response.isSuccessful} \n ${response.body()?.string()}")
```## New interface annotations
* `DisableCache` - Do not use caching* `PRIORITY` - Request priority
# Migrate from Retrofit
Just replace the reference globallymac global replacement shortcut keysοΌ`shift + command + R`
# Proguard
Shrinking and obfuscation rules are automatically included.# Thanks
[retrofit](https://github.com/square/retrofit)