-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
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: