我想使用Coil图像库从api加载带有之前设置的相同cookie的图像。因此,我希望在Ktor网络调用和使用Coil加载图像时都使用相同的HttpClient。 如何在Ktor和Coil之间共享相同的HttpClient?我假设,我需要以某种方式调整依赖关系,但我无法理解它。 我在共享模块中的KtorApiImpl class KtorApiImpl(log: Kermit) : KtorApi {
val baseUrl = BuildKonfig.baseUrl
// If this is a constructor property, then it gets captured
//
当我遇到这个问题时,我正在用android开发一个应用程序,我不知道这是不是一个已知的bug,或者我是否应该提交一个bug报告。代码如下:
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
data class Status(val msg: String, val integer: Int, val msg2:String)
interface API {
@GET("/json/gson")
suspe
我可以下载的文件,因为某种原因,我得到一个“内容是不允许在prolog。”错误。
我使用的是IntelliJ IDEA 2021.1.3 (终极版)
这就是我的build.gradle.kts的样子:
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
plugins {
application
kotlin("jvm") version "1.5.21"
}
group
我试图用KTOR运行本地服务器,并用测试来覆盖它。我编写了一些代码,在编写了一些测试之后,测试成功地启动了本地服务器并通过了测试。但是,如果我试图启动本地服务器,则会出现此错误。
线程“主”io.ktor.server.engine.ApplicationEngineEnvironmentReloading中的异常:接收类java.lang.AbstractMethodError不定义或继承接口io.ktor.application.ApplicationEnvironment的已解析方法‘抽象布尔getDevelopmentMode()’的实现。
我附上下面的代码和堆栈跟踪。
server
我正在尝试做一个简单的服务器,提供JSON格式的序列化列表。要序列化的列表是的多态序列化部分中的示例。
但是使用ktor的序列化特性,我得到了以下异常。
21:53:25.536 [nioEventLoopGroup-4-1] ERROR ktor.application - Unhandled: GET - /
java.lang.IllegalStateException: Serializing collections of different element types is not yet supported. Selected serializers: [DirectMessage
我尝试使用Kotlin创建一个全栈项目。由于多平台项目在Kotlin中是实验性的,因此没有太多可用信息,因此我尝试从IDEA项目向导的项目框架开始(Kotlin > JS Client和JVM Server)。它生成基本代码,甚至添加"hello world“类型的示例代码。 但是,当我构建项目并启动它(gradle run)时,网页控制台告诉我kotlin-js包不可用: The script from “http://127.0.0.1:8080/static/piggy-bank.js” was loaded even though its MIME type (“”)
我已经用ktor构建了一个测试应用程序,它在我的本地主机上运行得很好,但是当我将它上传到heroku并处理它时,它显示了构建是成功的,但是当我打开链接时,它表示应用程序错误。
这是我的应用程序类:
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
@kotlin.jvm.JvmOverloads
fun Application.module(testing : Boolean = true) {
val port = System.getenv("POR
我已经阅读了下面的文档:https://github.com/intuit/karate#path 我还在这些论坛上读到了许多关于相关主题的答案,最值得注意的是:How to dynamically create URL having path in between URL using Karate framework 然而,我仍然不能理解这个概念。也许我更像是一个新手,而不是一个典型的新手。我的问题是: The complete api: /sample/api/v1/sampleweb/{sampleweb}/webversion/{version}
Feature:
我想使用这种方法来验证我的应用程序中的客户机/服务器通信,但是我不知道为什么会出错。代码在超级简单和来自原来的ktor的例子。
服务器:
val myRealm = "Access to the '/' path"
val userTable: Map<String, ByteArray> = mapOf(
"jetbrains" to getMd5Digest("jetbrains:$myRealm:foobar"),
"admin" to getMd5Digest("admi
我在user.json文件夹中有一个名为src/main/resources的文件。
在我将应用程序打包到jar文件中之后,使用gradle执行命令
gradle distTar
我无法打开文件并得到这样的异常
Caused by: java.io.FileNotFoundException: file:/app/api-latest/lib/api-latest.jar!/user.json (No such file or directory)
我现在尝试以三种方式访问文件,所有这些都导致了一个FileNotFoundException:
1:
fun readFileFromRes
嘿我在Ktor工作。我发现这个可以在特定的平台iOS和Android中显示日志。但是,当我通过gradle构建这个命令时,在终端上运行这个命令时会出现错误。正常构建是成功的,没有任何错误,但是当我使用下面的命令时会出现错误。
./gradlew build --warning-mode all
误差
* What went wrong:
Could not determine the dependencies of task ':kotlinmultiplatformsharedmodule:compileIosMainKotlinMetadata'.
> Could
我正在跟踪 Ktor文档,但当我运行
./gradlew :fatjar:影子罐
在IntelliJ的终端上,就像它说的那样,我得到了以下错误:
失败:生成失败,出现异常。
哪里出了问题:根项目“com.menucabinet.ktor-菜单-橱柜”中找不到“fatjar”项目。
我一直在四处寻找,但有关这个问题的文件似乎有限.
这是我的秤:
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
我试图在iOS上使用Kotlin多平台代码(使用Ktor和Kotlin )。框架是正确生成的,并且可以调用一些公开的类/方法,而不存在任何问题。但是,如果我尝试添加以下内容(例如,在中这样做)。我得到“未声明类型‘KotlinCoroutineContext的使用”(我在SharedCode.h中看到它不存在)
import Foundation
import UIKit
import SharedCode
public class CoroutineDispatcher: Kotlinx_coroutines_core_nativeCoroutineScope {
overrid