|
|
|
@ -3,10 +3,6 @@
@@ -3,10 +3,6 @@
|
|
|
|
|
|
|
|
|
|
#include "Response.hxx" |
|
|
|
|
|
|
|
|
|
#ifdef EXTENSIONS_INJA |
|
|
|
|
#include <inja/inja.hpp> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
using namespace rpd; |
|
|
|
|
|
|
|
|
|
int Response::header(const char *key, const char *value) |
|
|
|
@ -16,29 +12,3 @@ int Response::header(const char *key, const char *value)
@@ -16,29 +12,3 @@ int Response::header(const char *key, const char *value)
|
|
|
|
|
key, |
|
|
|
|
value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef EXTENSIONS_INJA |
|
|
|
|
void Response::render(const char *path, nlohmann::json data) |
|
|
|
|
{ |
|
|
|
|
inja::Environment env; |
|
|
|
|
inja::Template tpl; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
std::string tplpath = DIST_PATH; |
|
|
|
|
tplpath += path; |
|
|
|
|
tpl = env.parse_template(tplpath); |
|
|
|
|
} catch (inja::FileError &e) { |
|
|
|
|
std::cerr << e.what() << std::endl; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
std::string result = env.render(tpl, data); |
|
|
|
|
body(result.c_str()); |
|
|
|
|
} catch (inja::RenderError &e) { |
|
|
|
|
std::cerr << e.what() << std::endl; |
|
|
|
|
status(rpd_res_st_internal_server_error); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|