Thread overview | |||||
---|---|---|---|---|---|
|
November 02, 2020 vibe.d get body of HTTPServerResponse | ||||
---|---|---|---|---|
| ||||
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? |
November 02, 2020 Re: vibe.d get body of HTTPServerResponse | ||||
---|---|---|---|---|
| ||||
Posted in reply to JG | 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 |
November 02, 2020 Re: vibe.d get body of HTTPServerResponse | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | 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.
|
Copyright © 1999-2021 by the D Language Foundation