Support OnHttpRequest Lua callback
If your redbean `/.init.lua` file defines a global callable named `OnHttpRequest` then redbean will delegate all serving control to your function. You may then restore the default serving paths, by calling the new `Route()`, `RouteHost()`, and `RoutePath()` APIs. Closes #150
This commit is contained in:
8
tool/net/demo/redbean-xhr.lua
Normal file
8
tool/net/demo/redbean-xhr.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
-- redbean xhr handler demo
|
||||
hdr = GetHeader('x-custom-header')
|
||||
if hdr then
|
||||
SetHeader('Vary', 'X-Custom-Header')
|
||||
SetHeader('X-Custom-Header', 'hello ' .. hdr)
|
||||
else
|
||||
ServeError(400)
|
||||
end
|
||||
Reference in New Issue
Block a user