Nacho Ruiz Martin
05/07/2022, 1:11 PMRyan Brink
05/07/2022, 2:52 PMdany giguere
05/07/2022, 9:16 PMobject Users: IntIdTable() {
val username = varchar("username", 128)
val email = varchar("email", 128)
val password = varchar("password", 1024)
}
class User(id: EntityID<Int>, username: String, email: String, password: String): IntEntity(id) {
companion object : IntEntityClass<User>(Users)
var username by Users.username
var email by Users.email
var password by Users.password
}
my serialization plugin is :
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.plugins.*
import io.ktor.server.application.*
fun Application.configureSerialization() {
install(ContentNegotiation) {
json()
}
}
when I call http://0.0.0.0:8080/users, I get
500: kotlinx.serialization.SerializationException: Serializer for class 'User' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
If I try adding @Serializable above the class User, my ide says
This class does not have a constructor
Cannot access 'Serializable': it is internal in '<http://kotlin.io|kotlin.io>'
You can view my project on this branch: https://github.com/danygiguere/ktor-kotlin-example/tree/setting-up-exposedJoakim Forslund
05/08/2022, 12:07 PMaSocket(selectorManager).tcp().connect
is not able to connect i.e the hostname is not reachable?jmfayard
05/08/2022, 3:45 PMgiso
05/09/2022, 10:13 AM.config()
and a dedicated Json configuration.
With Ktor 2 we now end up with a dedicated HttpClient containing 2 json registration, where the default json config is always winning, effectively disabling the dedicated Json configuration.
Is there a way to remove the first registration? Or is this maybe even a bug?martmists
05/09/2022, 11:55 PMresources/lang
as its root folder for internationalization instead of resources/templates
, or alternatively just use a single .properties file for all pages?Robert Kempton
05/10/2022, 2:18 AMMuhammad Talha
05/10/2022, 3:38 AMRobert Kempton
05/10/2022, 4:36 AMdodalovic
05/10/2022, 5:48 AMexternalServices
mocking with the 2.0.1
ktor version, but it doesn't kick in:
externalServices {
hosts("<https://api.sendinblue.com>") {
install(ContentNegotiation) {
json()
}
routing {
post("v3/smtp/email") {
call.response.status(HttpStatusCode.OK)
}
}
}
}
and then I call the API:
val response = <http://httpClient.post|httpClient.post>("<https://api.sendinblue.com/v3/smtp/email>") {
accept(ContentType.Application.Json)
contentType(ContentType.Application.Json)
header("api-key", apiKey)
But this mocking doesn't kick-in, rather the real thing.Joakim Forslund
05/10/2022, 8:04 AMribesg
05/10/2022, 9:57 AMpost<V1.OldPath> {
val resources = application.plugin(Resources)
val path = resources.resourcesFormat.encodeToPathPattern(V2.NewPath.serializer())
call.respondRedirect(path, permanent = true)
}
martmists
05/10/2022, 11:29 AM</html>
<p th:remove="${config.IS_DEVELOPMENT} ? none : all" class="filler">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet lacus felis. Praesent vitae dapibus metus. Phasellus vel ornare nunc. Suspendisse potenti. Nulla cursus lacus nisl, eu accumsan velit consequat id. Proin vel mollis nulla. Aliquam fermentum elit erat, vitae imperdiet mi gravida vehicula. Cras eu dui ex. Nam pretium nulla egestas turpis eleifend porta. In pellentesque, lorem at rhoncus gravida, odio jus</p>
ribesg
05/10/2022, 11:42 AMJulius
05/10/2022, 12:07 PMCannot access 'pipeline': it is internal in 'PluginBuilder'
Is there a workaround for this or an overall better way to implement this?Orhan Tozan
05/10/2022, 12:53 PMCaused by java.nio.channels.UnresolvedAddressException
at <http://sun.nio.ch.Net|sun.nio.ch.Net>.checkAddress(Net.java:107)
at <http://sun.nio.ch|sun.nio.ch>.SocketChannelImpl.connect(SocketChannelImpl.java:663)
at io.ktor.network.sockets.SocketImpl.connect$ktor_network(SocketImpl.kt:32)
at io.ktor.network.sockets.ConnectUtilsJvmKt.connect(ConnectUtilsJvm.kt:19)
at io.ktor.network.sockets.TcpSocketBuilder.connect(TcpSocketBuilder.kt:38)
at io.ktor.client.engine.cio.ConnectionFactory.connect(ConnectionFactory.kt:24)
at io.ktor.client.engine.cio.Endpoint$connect$2$connect$1.invokeSuspend(Endpoint.kt:179)
at io.ktor.client.engine.cio.Endpoint$connect$2$connect$1.invoke(Endpoint.kt:8)
at io.ktor.client.engine.cio.Endpoint$connect$2$connect$1.invoke(Endpoint.kt:4)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(UndispatchedKt.java:100)
at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:146)
at kotlinx.coroutines.TimeoutKt.withTimeoutOrNull(Timeout.kt:103)
at io.ktor.client.engine.cio.Endpoint.connect(Endpoint.kt:187)
at io.ktor.client.engine.cio.Endpoint.access$connect(Endpoint.kt:21)
at io.ktor.client.engine.cio.Endpoint$makeDedicatedRequest$1.invokeSuspend(Endpoint.kt:99)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Anyone knows how to solve this?dodalovic
05/10/2022, 3:28 PMdodalovic
05/10/2022, 3:29 PMMuhammad Talha
05/11/2022, 3:23 AMcharleskorn
05/11/2022, 9:00 AMktor-client-curl
to my Windows target (I’m using CIO for other targets).
However, when I try to build and run the tests for Windows on a Windows runner on GitHub Actions, I get compilation errors (in thread) about missing symbols… any ideas on what I’m missing?Paul Woitaschek
05/11/2022, 10:06 AMprintln(Url("<https://www.google.com/unicorns>").pathSegments)
Is it a bug that this returns a list of two strings, where the first is empty and the second one is unicorns?
Imo this should only contain unicorns
Jan
05/11/2022, 12:06 PMSam
05/12/2022, 9:07 AMribesg
05/12/2022, 11:19 AMcall.
in the second code block here https://ktor.io/docs/responses.html#statusHamza GATTAL
05/12/2022, 10:35 PMOkan Yıldırım
05/14/2022, 9:21 PMSamwel Otieno
05/16/2022, 9:14 AMMarcello Galhardo
05/16/2022, 5:19 PMpost
request where the body is always the same:
@Serializable
internal data class IgnoreRequest(val status: String = "IGNORE")
And I send it like this:
<http://httpClient.post|httpClient.post><Unit>(urlString = "whatever/${id.value}") { body = IgnoreRequest() }
The idea is that you are updating the status of item to “IGNORE”.
However, it looks like Ktor simple “does not send the body” when you have only default parameters:
19:06:37.052 I HttpClient: CONTENT HEADERS
19:06:37.052 I HttpClient: -> Content-Length: 3
19:06:37.055 I HttpClient: -> Content-Type: application/json; charset=utf-8
19:06:37.055 I HttpClient: BODY Content-Type: application/json; charset=utf-8
19:06:37.056 I HttpClient: BODY START
19:06:37.056 I HttpClient: {
19:06:37.056 I }
19:06:37.056 I HttpClient: BODY END
That feels wrong. The parameter is not optional (nullable). It simply has a default parameter where for this particular case won’t change… and Ktor is not sending anything (API fails for missing body).
Here is my question: is the Ktor’s behaviour by design? If yes, do you mind elaborating a little or letting me know where I can find details? If no, should I open a bug ticket for that? Thanks.Jorge Bo
05/16/2022, 8:40 PMJorge Bo
05/16/2022, 8:40 PMAleksei Tirman [JB]
05/17/2022, 1:40 PM