LazyPeopleHttp
suspend fun getUser(userId: Int): User
or
fun getUser(userId: Int): Call<User>
val user = hf.getUser(0).await()
val user by remember { hf.getUser(0).toState() }
Text("UserName=${user?.name}")
A type-safe HTTP client for Kotlin Multiplatform.
How to use
Step 1.add dependencies:
version
= 
- If it is a single platform, add it to build.gradle.kts in the app module directory
plugins {
...
id("com.google.devtools.ksp") version "1.8.20-1.0.10"
}
dependencies {
...
implementation("io.github.ltttttttttttt:LazyPeopleHttp-lib:$version")
ksp("io.github.ltttttttttttt:LazyPeopleHttp:$version")
}
- If it is multi-platform, add it to build.gradle.kts in the common module directory
plugins {
...
id("com.google.devtools.ksp") version "1.8.20-1.0.10"
}
...
val commonMain by getting {
dependencies {
...
api("io.github.ltttttttttttt:LazyPeopleHttp-lib:$version")
}
}
...
dependencies {
add("kspCommonMainMetadata", "io.github.ltttttttttttt:LazyPeopleHttp:$version")
}
- If you are using a version of ksp less than 1.0.9, the following configuration is required:
Ksp configuration
Step 2.interface declaration:
Step 3.interface use:
private val client = HttpClient {
defaultRequest {
url()
}
}
config = LazyPeopleHttpConfig(client)
hf = HttpFunctions::.createService(config)
hf.postB().enqueue()
hf.suspendGetB() or hf.postB().await()
remember { hf.().toState() }
Step 4.Custom configuration(Optional):
Step 5.R8/Proguard(Optional):
# The name used in your customized [CallAdapter]