Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 76527 invoked from network); 20 Nov 2010 12:43:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 20 Nov 2010 12:43:57 -0000 Received: (qmail 35091 invoked by uid 500); 20 Nov 2010 12:44:27 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 34967 invoked by uid 500); 20 Nov 2010 12:44:27 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 34959 invoked by uid 99); 20 Nov 2010 12:44:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Nov 2010 12:44:26 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=NORMAL_HTTP_TO_IP,SPF_NEUTRAL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [80.244.253.218] (HELO mail.traeumt.net) (80.244.253.218) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Nov 2010 12:44:21 +0000 Received: from [192.168.178.25] (brln-4d0cd615.pool.mediaWays.net [77.12.214.21]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.traeumt.net (Postfix) with ESMTPSA id 441E83C29B for ; Sat, 20 Nov 2010 13:44:00 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1082) Subject: Re: Problem getting simple rewrite rule to work From: Jan Lehnardt In-Reply-To: <60415AFB-BE00-4C11-A029-AE9607A38833@apache.org> Date: Sat, 20 Nov 2010 13:43:59 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <9844C269-EEB6-4934-B71C-1E531F9021C8@omnigroup.com> <4B34440B-1BC1-4631-B446-4B04D38DEA46@apache.org> <55D35EAA-4DED-4D70-B501-FFEFD7FDBC10@apache.org> <60415AFB-BE00-4C11-A029-AE9607A38833@apache.org> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1082) On 20 Nov 2010, at 13:08, Jan Lehnardt wrote: >=20 > On 19 Nov 2010, at 18:14, Timothy Wood wrote: >=20 >>=20 >> 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 >=20 > 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=3D1037194&view=3Drev Cheers Jan --=20 >=20 > Cheers > Jan > --=20 >=20 >>=20 >> -tim >>=20 >>=20 >> On Nov 19, 2010, at 8:51 AM, Jan Lehnardt wrote: >>=20 >>> Weird. >>>=20 >>> Can you share the full code (As a GitHub repo maybe)? >>>=20 >>> Cheers >>> Jan >>> --=20 >>>=20 >>> On 19 Nov 2010, at 17:06, Timothy Wood wrote: >>>=20 >>>>=20 >>>> Oops! >>>>=20 >>>> 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: >>>>=20 >>>> [ >>>> { >>>> "from": "", >>>> "to": "index.html", >>>> "method": "GET" >>>> } >>>> ] >>>>=20 >>>> still doesn't work (with or without the extra 'method' key), sadly. >>>>=20 >>>>=20 >>>> [Fri, 19 Nov 2010 15:59:33 GMT] [debug] [<0.31811.0>] Vhost = Target: '"/tinderbox/_design/app/_rewrite/"' >>>>=20 >>>>=20 >>>> [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=3D0.9,text/p= lain;q=3D0.8,image/png,*/*;q=3D0.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"}] >>>>=20 >>>> [Fri, 19 Nov 2010 15:59:33 GMT] [debug] [<0.31811.0>] OAuth = Params: [] >>>>=20 >>>> [Fri, 19 Nov 2010 15:59:33 GMT] [error] [<0.31811.0>] = function_clause error in HTTP request >>>>=20 >>>> [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}] >>>>=20 >>>> [Fri, 19 Nov 2010 15:59:33 GMT] [info] [<0.31811.0>] 127.0.0.1 - = - 'GET' /tinderbox/_design/app/_rewrite/ 500 >>>>=20 >>>> [Fri, 19 Nov 2010 15:59:33 GMT] [debug] [<0.31811.0>] httpd 500 = error response: >>>> {"error":"unknown_error","reason":"function_clause"} >>>>=20 >>>>=20 >>>> -tim >>>>=20 >>>>=20 >>>>=20 >>>> On Nov 19, 2010, at 4:51 AM, Jan Lehnardt wrote: >>>>=20 >>>>> Hi Tim, >>>>>=20 >>>>> can you try without the empty "query" object? >>>>>=20 >>>>> Cheers >>>>> Jan >>>>> --=20 >>>>>=20 >>>>> On 19 Nov 2010, at 08:39, Timothy Wood wrote: >>>>>=20 >>>>>>=20 >>>>>> I've been having some fun learning CouchDB and have started = writing up a replacement for an simple internal app, as a learning = exercise. >>>>>>=20 >>>>>> To make nice URLs, I looked at the notes on the rewrite handler = at = 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. >>>>>>=20 >>>>>> Configuration: >>>>>>=20 >>>>>> 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) >>>>>> =09 >>>>>> App pushed with couchapp. I can access the un-rewritten URL just = fine >>>>>>=20 >>>>>> My /etc/hosts has: >>>>>>=20 >>>>>> 127.0.0.1 tb-test >>>>>>=20 >>>>>> local.ini has these interesting bits: >>>>>>=20 >>>>>> [log] >>>>>> level =3D debug >>>>>>=20 >>>>>> [vhosts] >>>>>> tb-test:5984 =3D /tinderbox/_design/app/_rewrite >>>>>>=20 >>>>>> =09 >>>>>> my app/rewrites.js has exactly the example at the top of = couch_httpd_rewrite's handle_rewrite_req/3 >>>>>>=20 >>>>>> [ >>>>>> { >>>>>> "from:": "", >>>>>> "to": "index.html", >>>>>> "method": "GET", >>>>>> "query": {} >>>>>> } >>>>>> ] >>>>>> =09 >>>>>> when I open http://tb-test:5984/ my log file gets: >>>>>>=20 >>>>>> [Fri, 19 Nov 2010 07:17:59 GMT] [debug] [<0.103.0>] Vhost = Target: '"/tinderbox/_design/app/_rewrite/"' >>>>>>=20 >>>>>>=20 >>>>>> [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=3D0.9,text/p= lain;q=3D0.8,image/png,*/*;q=3D0.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"}] >>>>>>=20 >>>>>> [Fri, 19 Nov 2010 07:17:59 GMT] [debug] [<0.103.0>] OAuth = Params: [] >>>>>>=20 >>>>>> [Fri, 19 Nov 2010 07:17:59 GMT] [error] [<0.103.0>] = function_clause error in HTTP request >>>>>>=20 >>>>>> [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}] >>>>>>=20 >>>>>> [Fri, 19 Nov 2010 07:17:59 GMT] [info] [<0.103.0>] 127.0.0.1 - - = 'GET' /tinderbox/_design/app/_rewrite/ 500 >>>>>>=20 >>>>>> [Fri, 19 Nov 2010 07:17:59 GMT] [debug] [<0.103.0>] httpd 500 = error response: >>>>>> {"error":"unknown_error","reason":"function_clause"} >>>>>>=20 >>>>>>=20 >>>>>> 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 =3D) >>>>>>=20 >>>>>> Any suggestions about what I might be doing wrong would be much = appreciated. >>>>>>=20 >>>>>> Thanks! >>>>>>=20 >>>>>> -tim >>>>>>=20 >>>>>>=20 >>>>>=20 >>>>=20 >>>=20 >>=20 >=20