lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Is there a formalized way to "communicate" between a custom Xavante
handler and customized Cgilua handlers so that any Xavante request or
response data can be made available to Cgilua scripts?

If I understand the design intent, the place in Zavante to provide
customized behaviour is by writing a Zavante handler and registering
it in xavante/config.lua.  In Cgilua the user-definable parts appear
to be its script handlers and the open/close functions.

What I'm grasping for is the best way to customize the communication
between Xavante and Cgilua without hacking the source code.  A simple
case is the desire to make request header values that aren't defined
by cgilua.servervariable() available to Cgilua scripts .  For example,
some browsers pass the http authority information (e.g. the "user:pwd"
part of  "http://user:pwd@server:port/path";)  to the web server by
constructing an Authorization: header.  I would like to make that
header's value available to my Cgilua scripts to do customized

Another example of passing data from the customized side of Xavante to
Cgilua scripts is the match string determined by
xavante.httpd:parse_url().  I want one of my Cgilua scripts to
participate in decision making regarding the value of the match. 
Since Xavante puts just about everything it determines as a value in
the req table, it would be very handy to get at it in Cgilua scripts. 
But I want to take advantage of the security of the virtual
environment so I would like my custom Cgilua handler or open function
to limit what xavante-provided data is passed into the Cgilua scripts.

I could hack the xavante/cgiluahandler.lua code and add additional
headers to req.cgivars but, as I say, I don't want to modify the
source code if it can be avoided.

In the spirit of attempting to use the design-intended user-defineable
pieces, I've tried accessing the cgilua API (eg:
cgilua.addopenfunction() ) from within a custom xavante handler, but I
get an error from require"cgilua" because the SAPI table hasn't been
defined yet. (Cgilua assumes it is being referenced by a module that
sets up SAPI.) So this is starting to go around in circles.

Can someone more knowledgeable give me some advice on how to maximize
data interaction between Xavante and Cgilua in a standardized manner?

Thanks very much,