diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-09-13 23:50:12 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-10-25 01:03:37 +0200 |
commit | 673f38246ac3548caefec41183e3dd7477d9f6f6 (patch) | |
tree | b3b7682b14d8a81286f8b7fe2aa5239e5dfbf4b7 /modules/luci-base/htdocs | |
parent | ded8ccf93ec5163be35c41501869110e5dab30d1 (diff) |
treewide: separate Lua runtime resources
Move classes required for Lua runtime support into a new `luci-lua-runtime`
package. Also replace the `luci.http` and `luci.util` classes in
`luci-lib-base` with stubbed versions interacting with the ucode based
runtime environment.
Finally merge `luci-base-ucode` into the remainders of `luci-base`.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs')
-rwxr-xr-x | modules/luci-base/htdocs/cgi-bin/luci | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/modules/luci-base/htdocs/cgi-bin/luci b/modules/luci-base/htdocs/cgi-bin/luci index c5c9847346..442e427d41 100755 --- a/modules/luci-base/htdocs/cgi-bin/luci +++ b/modules/luci-base/htdocs/cgi-bin/luci @@ -1,5 +1,41 @@ -#!/usr/bin/lua -require "luci.cacheloader" -require "luci.sgi.cgi" -luci.dispatcher.indexcache = "/tmp/luci-indexcache" -luci.sgi.cgi.run() +#!/usr/bin/env ucode + +'use strict'; + +import { stdin, stdout } from 'fs'; + +import dispatch from 'luci.dispatcher'; +import request from 'luci.http'; + +const input_bufsize = 4096; +let input_available = +getenv('CONTENT_LENGTH') || 0; + +function read(len) { + if (input_available == 0) { + stdin.close(); + + return null; + } + + let chunk = stdin.read(min(input_available, len ?? input_bufsize, input_bufsize)); + + if (chunk == null) { + input_available = 0; + stdin.close(); + } + else { + input_available -= length(chunk); + } + + return chunk; +} + +function write(data) { + return stdout.write(data); +} + +let req = request(getenv(), read, write); + +dispatch(req); + +req.close(); |