incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: Problem getting simple rewrite rule to work
Date Sat, 20 Nov 2010 12:43:59 GMT

On 20 Nov 2010, at 13:08, Jan Lehnardt wrote:

> 
> On 19 Nov 2010, at 18:14, Timothy Wood wrote:
> 
>> 
>> Sure -- a my couchapp app (originally generated by couchapp, but trimmed down a bunch
since) and the one-line script I use to push is here <https://github.com/tjw/tinderbox-app>
> 
> mv rewrites.js rewrites.json

FWIW: I committed a small patch that gives you a more sensible error
message next time. It will be in the upcoming 1.0.2 and 1.1.0 releases:

  http://svn.apache.org/viewvc?rev=1037194&view=rev

Cheers
Jan
-- 

> 
> Cheers
> Jan
> -- 
> 
>> 
>> -tim
>> 
>> 
>> On Nov 19, 2010, at 8:51 AM, Jan Lehnardt wrote:
>> 
>>> Weird.
>>> 
>>> Can you share the full code (As a GitHub repo maybe)?
>>> 
>>> Cheers
>>> Jan
>>> -- 
>>> 
>>> On 19 Nov 2010, at 17:06, Timothy Wood wrote:
>>> 
>>>> 
>>>> Oops!
>>>> 
>>>> I just noticed that on my first two tries, one of the keys in the rewrite
was "from:" instead of "from".  Fixing that and using a rewrites.js of:
>>>> 
>>>> 	[
>>>> 		{
>>>> 			"from": "",
>>>> 			"to": "index.html",
>>>> 			"method": "GET"
>>>> 		}
>>>> 	]
>>>> 
>>>> still doesn't work (with or without the extra 'method' key), sadly.
>>>> 
>>>> 
>>>> 	[Fri, 19 Nov 2010 15:59:33 GMT] [debug] [<0.31811.0>] Vhost Target:
'"/tinderbox/_design/app/_rewrite/"'
>>>> 
>>>> 
>>>> 	[Fri, 19 Nov 2010 15:59:33 GMT] [debug] [<0.31811.0>] 'GET' /tinderbox/_design/app/_rewrite/
{1,1}
>>>> 	Headers: [{'Accept',"application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"},
>>>> 	          {'Accept-Encoding',"gzip, deflate"},
>>>> 	          {'Accept-Language',"en-us"},
>>>> 	          {'Connection',"keep-alive"},
>>>> 	          {'Host',"tb-test:5984"},
>>>> 	          {'User-Agent',"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5;
en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5"}]
>>>> 
>>>> 	[Fri, 19 Nov 2010 15:59:33 GMT] [debug] [<0.31811.0>] OAuth Params:
[]
>>>> 
>>>> 	[Fri, 19 Nov 2010 15:59:33 GMT] [error] [<0.31811.0>] function_clause
error in HTTP request
>>>> 
>>>> 	[Fri, 19 Nov 2010 15:59:33 GMT] [info] [<0.31811.0>] Stacktrace: [{couch_httpd_rewrite,'-handle_rewrite_req/3-lc$^1/1-1-',
>>>> 	                                  [<<"[\n\t{\n\t\t\"from\": \"\",\n\t\t\"to\":
\"index.html\"\n\t}\n]">>]},
>>>> 	             {couch_httpd_rewrite,handle_rewrite_req,3},
>>>> 	             {couch_httpd_db,do_db_req,2},
>>>> 	             {couch_httpd,handle_request_int,5},
>>>> 	             {mochiweb_http,headers,5},
>>>> 	             {proc_lib,init_p_do_apply,3}]
>>>> 
>>>> 	[Fri, 19 Nov 2010 15:59:33 GMT] [info] [<0.31811.0>] 127.0.0.1 - -
'GET' /tinderbox/_design/app/_rewrite/ 500
>>>> 
>>>> 	[Fri, 19 Nov 2010 15:59:33 GMT] [debug] [<0.31811.0>] httpd 500 error
response:
>>>> 	 {"error":"unknown_error","reason":"function_clause"}
>>>> 
>>>> 
>>>> -tim
>>>> 
>>>> 
>>>> 
>>>> On Nov 19, 2010, at 4:51 AM, Jan Lehnardt wrote:
>>>> 
>>>>> Hi Tim,
>>>>> 
>>>>> can you try without the empty "query" object?
>>>>> 
>>>>> Cheers
>>>>> Jan
>>>>> -- 
>>>>> 
>>>>> On 19 Nov 2010, at 08:39, Timothy Wood wrote:
>>>>> 
>>>>>> 
>>>>>> I've been having some fun learning CouchDB and have started writing
up a replacement for an simple internal app, as a learning exercise.
>>>>>> 
>>>>>> To make nice URLs, I looked at the notes on the rewrite handler at
<http://blog.couchone.com/post/443028592/whats-new-in-apache-couchdb-0-11-part-one-nice-urls>
and tried to set up my local sandbox to make rewrites work. But, so far I'm having no luck
and I'm not fluent enough in Erlang to figure out exactly what the error message means.
>>>>>> 
>>>>>> Configuration:
>>>>>> 
>>>>>> 	couchdb 1.0.1 installed with homebrew on Mac OS X 10.6.5 (using
a couchdb user/group and permissions fixed to be couchdb:couchdb on various /usr/local dirs
for couchdb)
>>>>>> 	
>>>>>> App pushed with couchapp.  I can access the un-rewritten URL just
fine <http://127.0.0.1:5984/tinderbox/_design/app/index.html>
>>>>>> 
>>>>>> My /etc/hosts has:
>>>>>> 
>>>>>> 	127.0.0.1 tb-test
>>>>>> 
>>>>>> local.ini has these interesting bits:
>>>>>> 
>>>>>> 	[log]
>>>>>> 	level = debug
>>>>>> 
>>>>>> 	[vhosts]
>>>>>> 	tb-test:5984 = /tinderbox/_design/app/_rewrite
>>>>>> 
>>>>>> 	
>>>>>> my app/rewrites.js has exactly the example at the top of couch_httpd_rewrite's
handle_rewrite_req/3
>>>>>> 
>>>>>> 	[
>>>>>> 		{
>>>>>> 			"from:": "",
>>>>>> 			"to": "index.html",
>>>>>> 			"method": "GET",
>>>>>> 			"query": {}
>>>>>> 		}
>>>>>> 	]
>>>>>> 	
>>>>>> when I open http://tb-test:5984/ my log file gets:
>>>>>> 
>>>>>> 	[Fri, 19 Nov 2010 07:17:59 GMT] [debug] [<0.103.0>] Vhost
Target: '"/tinderbox/_design/app/_rewrite/"'
>>>>>> 
>>>>>> 
>>>>>> 	[Fri, 19 Nov 2010 07:17:59 GMT] [debug] [<0.103.0>] 'GET'
/tinderbox/_design/app/_rewrite/ {1,1}
>>>>>> 	Headers: [{'Accept',"application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"},
>>>>>> 	          {'Accept-Encoding',"gzip, deflate"},
>>>>>> 	          {'Accept-Language',"en-us"},
>>>>>> 	          {'Connection',"keep-alive"},
>>>>>> 	          {'Host',"tb-test:5984"},
>>>>>> 	          {'User-Agent',"Mozilla/5.0 (Macintosh; U; Intel Mac OS
X 10_6_5; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5"}]
>>>>>> 
>>>>>> 	[Fri, 19 Nov 2010 07:17:59 GMT] [debug] [<0.103.0>] OAuth
Params: []
>>>>>> 
>>>>>> 	[Fri, 19 Nov 2010 07:17:59 GMT] [error] [<0.103.0>] function_clause
error in HTTP request
>>>>>> 
>>>>>> 	[Fri, 19 Nov 2010 07:17:59 GMT] [info] [<0.103.0>] Stacktrace:
[{couch_httpd_rewrite,'-handle_rewrite_req/3-lc$^1/1-1-',
>>>>>> 	                                  [<<"[\n\t{\n\t\t\"from:\":
\"\",\n\t\t\"to\": \"index.html\",\n\t\t\"method\": \"GET\",\n\t\t\"query\": {}\n\t}\n]">>]},
>>>>>> 	             {couch_httpd_rewrite,handle_rewrite_req,3},
>>>>>> 	             {couch_httpd_db,do_db_req,2},
>>>>>> 	             {couch_httpd,handle_request_int,5},
>>>>>> 	             {mochiweb_http,headers,5},
>>>>>> 	             {proc_lib,init_p_do_apply,3}]
>>>>>> 
>>>>>> 	[Fri, 19 Nov 2010 07:17:59 GMT] [info] [<0.103.0>] 127.0.0.1
- - 'GET' /tinderbox/_design/app/_rewrite/ 500
>>>>>> 
>>>>>> 	[Fri, 19 Nov 2010 07:17:59 GMT] [debug] [<0.103.0>] httpd
500 error response:
>>>>>> 	 {"error":"unknown_error","reason":"function_clause"}
>>>>>> 
>>>>>> 
>>>>>> So, it looks like it is finding the rewrite rule, but something about
what I'm going it giving it fits. The error message isn't particularly helpful =)
>>>>>> 
>>>>>> Any suggestions about what I might be doing wrong would be much appreciated.
>>>>>> 
>>>>>> Thanks!
>>>>>> 
>>>>>> -tim
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Mime
View raw message