This repository has been archived by the owner on Jan 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Allow deserializing a request and serializing a response using streams #39
Comments
I would be interested in seeing how this may be used. |
val request = inputStream.use { app.createRequest(it) }
val response = app.handleRequest(request, headers).get()
outputStream.use { response.writeTo(it) } That would be the rough outline. |
Is there an advantage to doing this? I would like to see if there's a use case for it. |
The advantage is to not having to first convert the whole body into a string and then parsing it as JSON. It would save memory and time. This is not a big issue as the bodies are likely pretty small but since it's already supported by Gson is seems beneficial to just expose it. |
I guess if it's slightly more efficient that would be neat, as long as the API doesn't change and tests succeed a PR would be appreciated. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
To avoid having to first create an intermediary JSON string it would be great if an
InputStream
/OutputStream
could be used to parse requests and serialize responses. Seeing as you are using gson already it would likely be a minor change.I'd be happy to open a PR if this is something you feel worth implementing.
The text was updated successfully, but these errors were encountered: