Hello! I am building a mutliplatform application w...
# ktor
n
Hello! I am building a mutliplatform application with ktor. My project structure looks like this:
Copy code
|- composeApp/
|- gradle/
|- iosApp/
|- server/
|  |- src/
|  |- build.gradle.kts
|- shared/
|  |- src/
|  |- build.gradle.kts
|- build.gradle.kts
|- settings.gradle.kts
Now I have
ktor-server
dependencies in
:server
and I have
ktor-client
dependencies in
:shared
. I am aware that although the
ktor-server-core
and
ktor-client-core
must belong to the respective modules, I want to know if there is any real difference between the dependencies of
ktor-*-content-negotation
and
ktor-*-resources
. Currently, what's happening is that I have two identical data classes with @Resources, but the tag comes from different dependencies. Is there a way to go around this issue? in other words,
:shared
has a class
@Resource("/article") data class Article(...)
and I have the same class in
:server
. But
:shared
uses
ktor-client-resources
while
:server
uses
ktor-server-resources
.
h
The Ressource annotation class is defined in the ktor-resources, so I don’t get your question.
And why do you use a client dependency in shared?
n
Hello. According to the ktor documentation, they mentioned I used use ktor-client-resources and ktor-server-resources. So that's what I have currently. I am a bit new to KMP, do you not do that? I was under the impression that shared is for the app's shared business logic code. Is it not?
a
You can store the resource classes in the shared module and refer to them in the client (this additional module can be created) and server modules, I think.
I want to know if there is any real difference between the dependencies of
ktor-*-content-negotation
and
ktor-*-resources
If you mean the difference between the
client
and
server
versions for each module, then they are different because they contain specific functionality for the HTTP client or HTTP server, respectively.
1
n
I went through the ktor git repo to see that ktor-resources is the common resources module for both client and server, something I was looking for. I think that can be made specific in the docs on ktor.