Hi dev@,
I've been wondering (and tinkering with) the idea of creating output
filters through mod_lua. If this has already been discussed, it was
before my time here, so please forgive any redundant ideas.

Essentially, what I'd like to do is be able to do the following:

LuaOutputFilter myTestFilter /www/filter.lua filter_handle
<FilesMatch "\.txt$">
    SetOutputFilter myTestFilter
</FilesMatch>

and then, through coroutines or some such, make the following filter in Lua:

-- [[ A simple filter mechanism ]] --
function filter_handle(r)
  coroutine.yield() -- Yield and wait for buckets
  while (buffer) do -- buckets are sent through the global var 'buffer'
                    -- and set to 'nil' when there are no more buckets
    local escaped = r:escape_html(buffer)
    coroutine.yield(escaped) -- pass on the bucket
  end
  return
end

I've already made and tested a prototype of this, and it seems like
something that could be of use to the public.

So, any feedback, comments, thoughts on this?

With regards,
Daniel.

Reply via email to