Closed mooziii closed 2 years ago
Im unsure if this is in scope tbh, might be intresting to see how many mods currently use this, either in a pack or by searching github. If anyone who is more familar with the kotlin ecosystem could provide their input that would be great.
It also doent appear that what you have is correctly including the dependencies, I had to append -jvm
to all of the names to get it to appear to work. Doing so created 7.2MB jar vs the previous 6MB.
I know that https://square.github.io/okhttp/ is quite popular as well, and I have helped a number of people include this in their mod. Java also now provides a modern HTTP client that I expect can be used from kotlin, what is the benefit of using one of these libraries over that?
It also doent appear that what you have is correctly including the dependencies, I had to append -jvm to all of the names to get it to appear to work. Doing so created 7.2MB jar vs the previous 6MB.
Seems kinda weird to me as i looked up all of them on the official ktor website
However i have the same problem, just added -jvm
, its building fine now
I know that https://square.github.io/okhttp/ is quite popular as well, and I have helped a number of people include this in their mod. Java also now provides a modern HTTP client that I expect can be used from kotlin, what is the benefit of using one of these libraries over that?
The main benefits of ktor are that it's build from the ground up using Coroutines and that it's supporting kotlinx.serialization meaning when you fetch something from e.g. an JSON API, you can directly serialize the json string into a data class. Without having to touch anything like JsonObject#get
.
forgot to commit xd
I know that https://square.github.io/okhttp/ is quite popular as well, and I have helped a number of people include this in their mod. Java also now provides a modern HTTP client that I expect can be used from kotlin, what is the benefit of using one of these libraries over that?
Most Kotlin programs should definitely use Ktor for non-blocking suspending requests and very good integration into the rest of the Kotlin ecosystem (serialization etc). Another big benefit is the super powerful Websocket API, I used it in several private mod projects by now for easy communication with a master server.
Using the Java HttpClient is not really a good thing to do in a Kotlin program, it is more of a workaround if you have to.
It also doent appear that what you have is correctly including the dependencies, I had to append -jvm to all of the names to get it to appear to work. Doing so created 7.2MB jar vs the previous 6MB.
Ktors dependency structure is a deeply nested tree and kind of impossible to include non-transitively.
Also, it is highly modularized making it a bit weird for FLK.
Im unsure if this is in scope tbh, might be intresting to see how many mods currently use this, either in a pack or by searching github. If anyone who is more familar with the kotlin ecosystem could provide their input that would be great.
Most Kotlin mods which make HTTP requests or use Websockets use Ktor and therefore include it themselves. However these are often private projects, I have not seen that many public mods using it (I mean making http requests is not at all common for most client mods).
Thanks for providing some input, I think its quite clear that this doesnt make sense in FLK.
We shouldn't be encoraging mods to make HTTP requests, if anything we should be encoraging the direct oppsite. We dont have a good solution in place to ensure we have all of the modules required (May be correct now, but change with an update)
You can easily include this in your own mod as required, or use the java libraries if its something simple.
Thanks for the PR, but for now atleast im going to close it. Sorry about that.
For anyone stumbling across this PR and now trying to include Ktor for himself, have a look at this guide for transitively including dependencies. Keep in mind though, that this should only be used if absolutely necessary - Ktor is such a case, since keeping track of all (changing) transitive dependencies and adding them manually is not humanly possible.
ktor is a official kotlin library to work with http requests.
I don't think anyone would need to create a server within a minecraft mod so i didn't add the server libraries