-
Notifications
You must be signed in to change notification settings - Fork 147
[napture] feat: Native JSON functions, require() #140
Conversation
Rust is too annoying for taburl to be used here, so the module must be a full url
|
require should work with local/relative paths in addition to urls, and Time() should absolutely use milliseconds (preferably unix time) instead of just seconds |
I attempted to support relative paths (03006c8) but had a bunch of issues, still not sure how that could be implemented. time already uses unix time, the reason for using seconds is compatibility with standard lua. We could have a argument/seperate function to get milliseconds |
|
Fetch already supported non Json ? |
|
My bad, looks like it does work, had an issue where github raw urls would just return a table with status 200 and no content so I assumed it just was not supported without looking at it enough. Though the current implementation is a bit inconsistent, requests that return json will give you the json as a table, where as other requests that don't return json will give you a table with the raw content and status. My implementation just gives you a table if its valid json, and a string with the raw response if it isn't. |
|
Should this comply with the sandbox change in #121? Quoting the code change: - let ok = lua.load(luacode).eval::<LuaMultiValue>();
+ if let Err(e) = lua.sandbox(true) {
+ lualog!("error", format!("failed to enable sandbox: {}", e));
+ Err(LuaError::runtime("failed to enable sandbox"))
+ } else {
+ let ok = lua.load(luacode).eval::<LuaMultiValue>();
+ }Also, |
|
Considering #121 has been merged, It is probably a good idea to do so, will update asap. Still need an opinion on the changes to fetch and suggestion from the previous comment |
I agree with this but it will break current websites, I propose to revert the fetch behavior to the old one |
|
Alright fetch will be reverted. |
|
It doesn't seem like you've reverted the fetch implementation as I'm getting this error (which doesn't occur on the I've tested the JSON utility and it seems to work, I'm gonna check out the require feature in a bit |
|
Alright, everything seems to work |
|
epic |
This PR adds:
JSON
Can be just used as
json.stringify()andjson.parse(), no need to require/import anythingTime
Used as
time(), returns seconds instead of millis like the standard luaos.time()Require
Fetches, loads and executes some lua code from a url, and returns the output
Fetch
Fetch now supports responses that do not return JSON, for backwards compatibility and simplicity, a table will be returned if the response is valid JSON