Hi is it possible to embedd a ktor server in an an...
# ktor
i
Hi is it possible to embedd a ktor server in an android or ios app without an engine and instead just call the server diretly from a ktor client in the same app? Basically the user should be able to host the server in the app without necessarily having a dedicated server.
a
Sounds like a mock client to me. No???
i
Interesting will see if it works for my use case. Thanks!
One question does this also work for Kotlin/JS? The server doesn't seem to support that target but is there another way using the mock client?
a
The ktor mock client should support javascript. Let me look it up first
https://repo.maven.apache.org/maven2/io/ktor/ktor-client-mock-js/ it is available in maven central You'll have to handle your requests from with in the app though, through the
MockEngine
i
This seems quite complicated to be fair. There is no way to point a client to directly call a server that is available in the same code base? That way is simple to either call the local sever or over the network.
Still this would not work for Kotlin/JS as the server doesn't support that target.
a
perhaps I should ask what your expectation is, how do you intend to "point" the client to this supposedly local server?? Sample code would be nice