You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Timothy Wood <tj...@omnigroup.com> on 2010/11/19 08:39:28 UTC

Problem getting simple rewrite rule to work

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



Re: Problem getting simple rewrite rule to work

Posted by Timothy Wood <tj...@omnigroup.com>.
On Nov 19, 2010, at 9:40 AM, Stefan Klein wrote:
> I think you have to use:[
> 
> {
>   "from": "/",
>   "to": "index.html",
>   "method": "GET"
> }
> ]
> 
> since rewrites are relativ to ".../_rewrites" and not ".../_rewrites/"
> 
> There is an example in the "What's New in CouchDB 0.11 & 1.0" webcast http://www.youtube.com/watch?v=4jtBQf41Ppc#t=11m30s

  No luck with that either. Using:

[
	{
		"from": "/",
		"to": "index.html",
		"method": "GET"
	}
]

  I get:

[Fri, 19 Nov 2010 23:28:19 GMT] [info] [<0.26519.1>] 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}\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}]

  I’ll keep watching the video to see if anything else pops out that I might need to configure.  Thanks for the link!

-tim


Re: Problem getting simple rewrite rule to work

Posted by Stefan Klein <st...@googlemail.com>.
Am 19.11.2010 17:06, schrieb Timothy Wood:
> 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.
I think you have to use:[

  {
    "from": "/",
    "to": "index.html",
    "method": "GET"
  }
]

since rewrites are relativ to ".../_rewrites" and not ".../_rewrites/"

There is an example in the "What's New in CouchDB 0.11 & 1.0" webcast 
http://www.youtube.com/watch?v=4jtBQf41Ppc#t=11m30s

regards,
Stefan

Re: Problem getting simple rewrite rule to work

Posted by Timothy Wood <tj...@omnigroup.com>.
On Nov 20, 2010, at 4:43 AM, Jan Lehnardt wrote:

>> 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

  That did the trick -- thanks (both for the fix and for the improved error message)!

-tim


Re: Problem getting simple rewrite rule to work

Posted by Jan Lehnardt <ja...@apache.org>.
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
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Problem getting simple rewrite rule to work

Posted by Jan Lehnardt <ja...@apache.org>.
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

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
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Problem getting simple rewrite rule to work

Posted by Timothy Wood <tj...@omnigroup.com>.
  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>

-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
>>>> 
>>>> 
>>> 
>> 
> 


Re: Problem getting simple rewrite rule to work

Posted by Jan Lehnardt <ja...@apache.org>.
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
>>> 
>>> 
>> 
> 


Re: Problem getting simple rewrite rule to work

Posted by Timothy Wood <tj...@omnigroup.com>.
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
>> 
>> 
> 


Re: Problem getting simple rewrite rule to work

Posted by Timothy Wood <tj...@omnigroup.com>.
With a rewrites.js of:

	[
		{
			"from:": "",
			"to": "index.html",
			"method": "GET"
		}
	]

I get a similar result:

	[Fri, 19 Nov 2010 15:51:24 GMT] [debug] [<0.31304.0>] Vhost Target: '"/tinderbox/_design/app/_rewrite/"'


	[Fri, 19 Nov 2010 15:51:24 GMT] [debug] [<0.31304.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:51:24 GMT] [debug] [<0.31304.0>] OAuth Params: []

	[Fri, 19 Nov 2010 15:51:24 GMT] [error] [<0.31304.0>] function_clause error in HTTP request

	[Fri, 19 Nov 2010 15:51:24 GMT] [info] [<0.31304.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}\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:51:24 GMT] [info] [<0.31304.0>] 127.0.0.1 - - 'GET' /tinderbox/_design/app/_rewrite/ 500

	[Fri, 19 Nov 2010 15:51:24 GMT] [debug] [<0.31304.0>] httpd 500 error response:
	 {"error":"unknown_error","reason":"function_clause"}


Thanks!

-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
>> 
>> 
> 


Re: Problem getting simple rewrite rule to work

Posted by Jan Lehnardt <ja...@apache.org>.
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
> 
>