vibe.d get body of HTTPServerResponse
Steven Schveighoffer
schveiguy at gmail.com
Mon Nov 2 17:02:01 UTC 2020
On 11/2/20 10:10 AM, JG wrote:
> I am trying to get the body the response generated by:
>
> res.render!("index.dt");
>
> where res is of type HTTPServerResponse
>
> Does anyone know how I might go about this?
>
That is a convenience wrapper to diet-ng:
https://github.com/vibe-d/vibe.d/blob/70b50fdb9cd4144f1a5007b36e6ac39d4731c140/http/vibe/http/server.d#L337-L346
Instead, create your own output range (maybe a char[] appender?) and
compile to that yourself:
import diet.html : compileHTMLDietFile;
import std.array : appdender;
auto app = appender!(char[]);
compileHTMLDietFile!("index.dt")(app);
auto resultingHTML = app.data;
-Steve
More information about the Digitalmars-d-learn
mailing list