Skip to content

Commit

Permalink
feat: add useragent
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Dec 7, 2022
1 parent 2ab510a commit 62963cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 16 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")

import com.codingfeline.buildkonfig.compiler.FieldSpec
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import java.io.FileInputStream
import java.util.*
Expand Down Expand Up @@ -63,11 +64,16 @@ afterEvaluate {
plugins {
kotlin("multiplatform") version "1.7.21"
kotlin("plugin.serialization") version "1.7.21"
id("io.codearte.nexus-staging") version "0.30.0"
id("com.dorongold.task-tree") version "2.1.0"

id("com.android.library")

id("io.codearte.nexus-staging") version "0.30.0"
id("maven-publish")
id("signing")

id("com.dorongold.task-tree") version "2.1.0"

id("com.codingfeline.buildkonfig") version "0.13.3"
}

kotlin {
Expand Down Expand Up @@ -155,6 +161,14 @@ kotlin {
}
}

buildkonfig {
packageName = "dev.zxilly.notify.sdk"

defaultConfigs {
buildConfigField(FieldSpec.Type.STRING, "VERSION", version.toString())
}
}

val hostOs: String = System.getProperty("os.name")
val isMacosX64 = hostOs == "Mac OS X"
val isLinuxX64 = hostOs == "Linux"
Expand Down
7 changes: 6 additions & 1 deletion src/commonMain/kotlin/dev/zxilly/notify/sdk/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.zxilly.notify.sdk
import dev.zxilly.notify.sdk.entity.*
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.*
Expand All @@ -16,12 +17,16 @@ class Client private constructor(
private val userID: String,
private val endpoint: String
) {
private val client = HttpClient() {
private val client = HttpClient {
install(ContentNegotiation) {
json(Json {
ignoreUnknownKeys = true
})
}
// set useragent
install(UserAgent) {
agent = "znotify-kt-sdk/${BuildKonfig.VERSION}"
}
}

private suspend inline fun check() {
Expand Down

0 comments on commit 62963cd

Please sign in to comment.