Skip to content

Commit 62963cd

Browse files
committed
feat: add useragent
1 parent 2ab510a commit 62963cd

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

build.gradle.kts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")
22

3+
import com.codingfeline.buildkonfig.compiler.FieldSpec
34
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
45
import java.io.FileInputStream
56
import java.util.*
@@ -63,11 +64,16 @@ afterEvaluate {
6364
plugins {
6465
kotlin("multiplatform") version "1.7.21"
6566
kotlin("plugin.serialization") version "1.7.21"
66-
id("io.codearte.nexus-staging") version "0.30.0"
67-
id("com.dorongold.task-tree") version "2.1.0"
67+
6868
id("com.android.library")
69+
70+
id("io.codearte.nexus-staging") version "0.30.0"
6971
id("maven-publish")
7072
id("signing")
73+
74+
id("com.dorongold.task-tree") version "2.1.0"
75+
76+
id("com.codingfeline.buildkonfig") version "0.13.3"
7177
}
7278

7379
kotlin {
@@ -155,6 +161,14 @@ kotlin {
155161
}
156162
}
157163

164+
buildkonfig {
165+
packageName = "dev.zxilly.notify.sdk"
166+
167+
defaultConfigs {
168+
buildConfigField(FieldSpec.Type.STRING, "VERSION", version.toString())
169+
}
170+
}
171+
158172
val hostOs: String = System.getProperty("os.name")
159173
val isMacosX64 = hostOs == "Mac OS X"
160174
val isLinuxX64 = hostOs == "Linux"

src/commonMain/kotlin/dev/zxilly/notify/sdk/Client.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dev.zxilly.notify.sdk
33
import dev.zxilly.notify.sdk.entity.*
44
import io.ktor.client.*
55
import io.ktor.client.call.*
6+
import io.ktor.client.plugins.*
67
import io.ktor.client.plugins.contentnegotiation.*
78
import io.ktor.client.request.*
89
import io.ktor.client.request.forms.*
@@ -16,12 +17,16 @@ class Client private constructor(
1617
private val userID: String,
1718
private val endpoint: String
1819
) {
19-
private val client = HttpClient() {
20+
private val client = HttpClient {
2021
install(ContentNegotiation) {
2122
json(Json {
2223
ignoreUnknownKeys = true
2324
})
2425
}
26+
// set useragent
27+
install(UserAgent) {
28+
agent = "znotify-kt-sdk/${BuildKonfig.VERSION}"
29+
}
2530
}
2631

2732
private suspend inline fun check() {

0 commit comments

Comments
 (0)