aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStanisław Zagórowski <hasohasacz@gmail.com>2024-01-19 22:38:49 +0100
committerStanisław Zagórowski <hasohasacz@gmail.com>2024-01-19 22:38:49 +0100
commit90d05fd9911596db33a20a164f92a51ffd067053 (patch)
tree0aaab8eb31d532f79090c466c3f3b3c9c3529d87 /src
parent2e77359c2f1cab769e34cde5c0dfb90a2d52b00b (diff)
fix: body as string instead of table of numbers, write numbers and booleans to html
Diffstat (limited to 'src')
-rw-r--r--src/luax/mod.rs2
-rw-r--r--src/server.rs2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/luax/mod.rs b/src/luax/mod.rs
index e5adc9a..70e7b34 100644
--- a/src/luax/mod.rs
+++ b/src/luax/mod.rs
@@ -63,6 +63,8 @@ pub fn table_to_html<W: std::io::Write>(table: rlua::Table, f: &mut W) -> Result
match child? {
rlua::Value::Table(child) => table_to_html(child, f)?,
rlua::Value::String(s) => write!(f, "{}", s.to_str()?)?,
+ rlua::Value::Boolean(b) => write!(f, "{}", b)?,
+ rlua::Value::Number(n) => write!(f, "{}", n)?,
_ => return Err(LuaXError::NonTableChildren.into()),
}
}
diff --git a/src/server.rs b/src/server.rs
index 307aa0c..7aa3cec 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -186,7 +186,7 @@ impl State {
let route: rlua::Function = manifest.get("route")?;
let method = method.as_str();
- let body: Vec<u8> = body.to_bytes().to_vec();
+ let body: rlua::String = ctx.create_string(&body.to_bytes().to_vec())?;
let res: rlua::Result<(rlua::Integer, rlua::Value)> =
route.call((path.clone(), method, body));