Origin-OS
Origin-OS copied to clipboard
[OSL] RTR Hosting Syntax
Users have no way to host RTR websites locally.
def "evalOSL(OSL)"
run [].append("out = (" ++ OSL ++ ")")
return out
endef
urls = {
"/eval":"evalOSL()"
}
/*
// if i receive a request like:
{
data: {
endpoint: "/eval",
parameters: ""
}
}
*/
if new_network_data (
if packet.data.type == "rtr" (
// ensure that the packet is an rtr packet
endpoint = packet.data.endpoint
parameters = packet.data.parameters
from = packet.origin
// get the sender of the packet
command = urls[endpoint]
// get the endpoint
command.replace("/","")
// remove the slash
func = Globals().functions[command]
/* returns a function object
{
"type": "function",
"code": ["run [].append(\"out = (\" ++ OSL ++ \")\")","return out"],
"parameters": ["OSL"],
"line": 1,
"scope": "main"
}
*/
from.roturSend(func.run(parameters), packet.source)
)
new_network_data = false
packet = ""
network_data = ""
)
I'll have to make this sort of thing possible in CRL, nice job!
Edit: looks like normal rotur, should be easy enough
thx!
still need to add the globals system, but after that, this should be possible #173
this code now works