[erlang-questions] inets - mod_esi accessing #mod.config_db
Serge Aleynikov
saleyn@REDACTED
Sat May 24 14:37:06 CEST 2008
I am having trouble trying to figure out how to get the web server's
document_root (or how to convert some RequestURI's document path to a
filesystem path) inside a mod_esi's execution function.
Say, we have a function callable by a client through mod_esi:
get_image(SessionID, Env, Input) ->
ImageFile = doc_root(filename:join(["/images", Input, ".gif"])),
case read_image(ImageFile) of
{ok, Image} ->
mod_esi:deliver(SessionID, [
"Content-type: image/gif\r\n\r\n",
]);
{error, Reason} ->
mod_esi:deliver(SessionID, [
"status: ", integer_to_list(400), " Not Found\r\n\r\n"
])
end.
doc_root(DocPath) ->
???
How do we implement the function doc_root? It's quite easy if we have
access to the #mod.config_db:
mod_alias:path(Info#mod.data, Info#mod.config_db, DocPath)
However #mod{} record is not passed to the mod_esi's callback, so it's
not possible to use mod_alias:path/3 as is.
Serge
More information about the erlang-questions
mailing list