Open ansman opened 4 years ago
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.