https://kotlinlang.org logo
#ktor
Title
# ktor
t

thanh

08/20/2021, 7:59 PM
Hi 👋 does someone has a best practice for sharing code between ktor server and multiplatform client?
all the things 1
d

Didier Villevalois

08/21/2021, 12:17 AM
I don't know about any best practice. I personally use gradle sub-projects, one being a multi-platform library with my
@Serializable
definitions and shared code. I make sure it has the required targets for my server and clients.
👍 2
c

CLOVIS

08/22/2021, 4:30 PM
I'm doing the same, full project here: https://gitlab.com/arcachon-ville/formulaide
api
is shared,
client
has the Ktor client,
server
has the Ktor server.
💯 1
h

hfhbd

08/23/2021, 9:01 PM
I do share the API (client) too:
fun API(client: HttpClient)…
. In the server test, you can use its mock client to test the API too, and ensure using the same „real“ api functions defined in your shared module.
c

CLOVIS

08/24/2021, 8:47 AM
That's a nice idea.