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

Ahmed Riyadh

03/26/2024, 11:02 AM
The Ktor resources plugin doesn't seems to work with post method function in routing and it work only after chaning the import, for more info is there any way to fix this workaround? it might causing bug as the import statement can be changed or removed in the future by other developers
a

AdamW

03/26/2024, 12:21 PM
What do you mean ”workaround”? Importing the required function is hardly a workaround 😅
👍 1
a

Ahmed Riyadh

03/26/2024, 12:23 PM
That's because you have to look at the imports and change manually change it, it can't be done by the IDE, there is another function with different import with automatically used, in the future you might remove it and there is no sign of error but it will cause a bug since that route won't work
At least that's the way how I see it (maybe it's just me but it doesn't matter), it doesn't has to be everyone perspective, I'm just wondering if there is a better solution
:)
a

Aleksei Tirman [JB]

03/26/2024, 12:36 PM
Can you please file an issue about that?
a

Ahmed Riyadh

03/26/2024, 12:38 PM
Are you sure it's an issue (I'm not sure)?, you already closed the issue created by Artur Mkrtchian and update it as a question which was year ago
a

AdamW

03/26/2024, 12:39 PM
Resource route builders are not type-safe in the sense that they all accept
Any
, so all of the route handlers in
RoutingBuilder
with a single generic suffer from this ”issue” (post, put, patch). One way you can get it to fail at compile time is to use the undocumented
post<A, B>
with two generic arguments where A is your resource and B is the request body. It will always resolve to the correct import also.
👍 1
a

Aleksei Tirman [JB]

03/26/2024, 12:40 PM
That's because it was a question and my recommendation helped solving the problem.
I mean the user's problem was solved.
a

Ahmed Riyadh

03/26/2024, 12:41 PM
Can you please file an issue about that?
So should I open a new issue?
a

Aleksei Tirman [JB]

03/26/2024, 12:43 PM
Yes, please.
a

Ahmed Riyadh

03/26/2024, 12:43 PM
Sure