2021-05-18 16:57:33 +02:00
|
|
|
@file:Suppress("FunctionName")
|
|
|
|
|
2021-06-05 20:43:55 +02:00
|
|
|
package common
|
2021-05-18 16:57:33 +02:00
|
|
|
|
2021-05-18 21:31:09 +02:00
|
|
|
import io.ktor.client.HttpClient
|
2021-05-20 12:23:08 +02:00
|
|
|
import io.ktor.client.features.HttpTimeout
|
2021-05-18 21:31:09 +02:00
|
|
|
import io.ktor.client.features.json.JsonFeature
|
|
|
|
import io.ktor.client.features.json.serializer.KotlinxSerializer
|
2021-05-24 21:28:25 +02:00
|
|
|
import io.ktor.client.features.logging.DEFAULT
|
|
|
|
import io.ktor.client.features.logging.LogLevel
|
|
|
|
import io.ktor.client.features.logging.Logger
|
|
|
|
import io.ktor.client.features.logging.Logging
|
2021-05-18 21:31:09 +02:00
|
|
|
import kotlinx.serialization.json.Json
|
2021-05-18 16:57:33 +02:00
|
|
|
|
|
|
|
internal object Common {
|
|
|
|
const val GITHUB_API = "https://api.github.com"
|
|
|
|
fun START_SECTION(tagName: String = "HTI") = "<!--START_SECTION:$tagName-->"
|
|
|
|
fun END_SECTION(tagName: String = "HTI") = "<!--END_SECTION:$tagName-->"
|
|
|
|
const val USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0"
|
|
|
|
}
|
2021-06-05 20:43:55 +02:00
|
|
|
|
2021-05-18 21:31:09 +02:00
|
|
|
internal val client = HttpClient {
|
2021-05-20 12:23:08 +02:00
|
|
|
install(HttpTimeout)
|
2021-05-18 21:31:09 +02:00
|
|
|
install(JsonFeature) {
|
|
|
|
serializer = KotlinxSerializer(
|
|
|
|
Json {
|
|
|
|
ignoreUnknownKeys = true
|
|
|
|
isLenient = true
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2021-05-24 21:28:25 +02:00
|
|
|
install(Logging) {
|
|
|
|
logger = Logger.DEFAULT
|
|
|
|
level = LogLevel.INFO
|
|
|
|
}
|
2021-05-18 21:31:09 +02:00
|
|
|
}
|