v0.24.0 #774
bitspittle
announced in
Announcements
v0.24.0
#774
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In this update, we took some time to focus on the backend API, adding support for multipart requests. We also revisited the associated frontend APIs (and deprecated a bunch of them) paving the way for more improvements to follow.
This release also makes markdown handling more robust, and it raises the versions of kotlin to 2.3.10, compose (html) to 1.10.0, and compose (runtime) to 1.10.2 (now sourced from androidx).
Important
Planning to upgrade? Review instructions in the README.
Changes
Frontend
window.getSelectionanddocument.getSelectionholdsIncontracts toModifier.thenIf/UnlessandCssStyleVariant.thenIf/Unlessthenlambda block.Modifier.displayBetweenwhich was broken since a prior rename{param?}) are now only allowed in the final position of a routebaseblock in theirCssStyleblock.window.api.bytes(...)changed towindow.api.getBytes(...))Backend
Added support for multipart request bodies.
Request.BodyandResponse.BodyAPIs as a side effectAdded a user data property on
RequestandResponseclassesMarkdown
attrslambda blocks instead of string manipulationGradle
nullerror that could occur in the Gradle task listenerkotlin-dslplugin, added Gradle assignment plugin)Misc
Thanks!
Notes
Multipart requests
Requests using multipart forms is outside the scope of these release notes, but consider reading the official docs on the topic for more information.
Kobweb does not yet have an idiomatic way to send a multipart request (we will add this into a future release, but you can use the stdlib for this, leveraging
FormData,RequestInit, andwindow.fetchAPIs for now.)The following FE code (imagine in a
@Pagesomewhere) lets the user pick a file from their machine and send it to the server, using multipart forms to send both the file itself and an extra description as metadata:Then, to handle a multipart request on the backend, write an API endpoint that uses
req.body.multipart()to query it. The following endpoint is just a demo and returns diagnostic information about what was sent back as body text:Our API is inspired by, but (we think) slightly more Kotlin idiomatic than, the ktor version.
Migrating frontend / backend APIs
Changes in this release caused us to reevaluate our APIs used for communicating between the frontend and backend, after adding multipart support challenged simple assumptions that I had mistakenly made a long time ago.
Fortunately, migration should be pretty easy, and it is hoped that most projects won't even notice the changes, or at least, will just need to accept IDE suggestions on deprecated lines of code.
HTTP responses expecting raw bytes
The APIs that send HTTP verb requests and expect raw bytes back have been renamed to be more explicit, e.g.
In a near future release of Kobweb, the old
get,post, etc. methods will be repurposed to return a different, richer type.Reading / writing body text
Before, we put read/write extension methods directly on the Request and Response objects, but body content can be more flexible than I originally realized, so I tweaked these APIs and moved them onto the exposed body objects instead.
We also now support alternate ways of reading body content, i.e.
body.stream()andbody.bytes()Querying body text is async now
Previously, Kobweb read the bytes out of the body itself on the backend and converted it into a string, but this was not compatible with some kind of response bodies. So now, we let the user query the body contents at their convenience.
If you run into an error that an API call you wrote cannot call a suspend method, this generally means you may have to update its signature to be explicitly suspend:
Full Changelog: v0.23.3...v0.24.0
This discussion was created from the release v0.24.0.
Beta Was this translation helpful? Give feedback.
All reactions