www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - vibe.d get body of HTTPServerResponse

reply JG <someone somewhere.com> writes:
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?
Nov 02 2020
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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
Nov 02 2020
parent JG <someone somewhere.com> writes:
On Monday, 2 November 2020 at 17:02:01 UTC, Steven Schveighoffer 
wrote:
 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
Thank you very much.
Nov 02 2020