Hi,
I'm looking for documentation re the "head" and "req" arguments supplied
to list functions (as mentined in the _Definitive Guide_.) It's not
clear to me how to extract information from them. My specific need is as
follows:
I have a couch database of documents with attached images. I have a
view with a map function that emits pairs of the form:
(doc_id, name_of_attached_image)
And I have a list function that assembles these images into a web page:
function(head, req) {
provides('html',
function(){
var s = '<!DOCTYPE html><html><body>';
while (row = getRow())
s += '<img src=\"http://127.0.0.1:5984/db/' +\
row['value'][0] + '/' + \
row['value'][1] + '\" />';
s += '</body></html>';
send(s);})}
Everything works fine locally, but if I want the same functionality
on my remote server (where 5984 is bound to 0.0.0.0 rather than
127.0.0.1) I need to replace 127.0.0.1 in the list function with some
variable that evaluates to the name of the host being queried. I'm
guessing that the hostname can be extracted somehow from the head or
req arguments of the list function, but need a pointer to some info.
Thanks,
Catherine