CVu, Code Critique, and D

Anton Fediushin fediushin.anton at yandex.ru
Tue Jun 19 19:05:23 UTC 2018


On Tuesday, 19 June 2018 at 13:55:34 UTC, Steven Schveighoffer 
wrote:
> On 6/19/18 9:43 AM, Anton Fediushin wrote:
>> On Tuesday, 19 June 2018 at 08:56:05 UTC, Russel Winder wrote:
>>> I would like to build a back-end server that performs some 
>>> processing on the body of the HTTP request it receives.  To 
>>> begin with, I would like it to simply echo the request body 
>>> back to the client.
>> 
>> There is vibe.web.rest which covers 90% of everything one 
>> might need for their back-end application. There's practically 
>> no reason to bother with bodyReaders/Writers.
>
> The one reason I found is that the REST interface must 
> serialize everything before returning.
>
> For example, if you are looking for ALL the data from your 
> database, instead of streaming it while parsing the database, 
> you have to serialize the entire database to an in-memory 
> array, and return that, which the REST interface will then 
> serialize to JSON.
>
> In my case, I had to output the data manually to avoid insane 
> memory consumption.
>
> -Steve

Indeed, that's one of the cases where vibe.web.rest isn't as 
helpful. Interesting thing is, vibe.web.web provides such 
functionality (methods can return InputStream) even though:

> Module vibe.web.web
> Implements a declarative framework for building web interfaces.

> This module contains the sister funtionality to the 
> vibe.web.rest module. While > the REST interface generator is 
> meant for stateless machine-to-machine  communication, this 
> module aims at implementing user facing web services. Apart 
> from that, both systems use the same declarative approach.

I have no idea why machine-to-machine communication can't have 
InputStream and machine-to-user can.



More information about the Digitalmars-d mailing list