cosmopolitan/tool/net/demo/redbean-xhr.lua
Justine Tunney 472b95fea3 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
2021-04-24 17:27:12 -07:00

8 lines
192 B
Lua

-- 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