Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06BF9183D1 for ; Sat, 17 Oct 2015 19:23:56 +0000 (UTC) Received: (qmail 87017 invoked by uid 500); 17 Oct 2015 19:23:55 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 86952 invoked by uid 500); 17 Oct 2015 19:23:55 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 86940 invoked by uid 99); 17 Oct 2015 19:23:55 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Oct 2015 19:23:55 +0000 Received: from [10.0.0.13] (ip5b41b523.dynamic.kabel-deutschland.de [91.65.181.35]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id E30881A0331 for ; Sat, 17 Oct 2015 19:23:54 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) Subject: Re: [PROPOSAL] Allow rewrites to be JS function From: Jan Lehnardt In-Reply-To: Date: Sat, 17 Oct 2015 21:23:51 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <467C2D4D-971D-4E5C-A9AA-D3B17FD18220@b2w.com> <7EB4541B-630C-47A8-A2FF-2E4B04EE8EB1@b2w.com> <4870F21F-1B77-4D09-8D3F-204808FED288@b2w.com> <757D74C8-0CF2-41CE-A1FE-C0F261D67698@b2w.com> To: dev@couchdb.apache.org X-Mailer: Apple Mail (2.3094) Not to rain on your parade, but 2.0 is in feature freeze, this will have = to wait for 2.1., but there is no reason that can=E2=80=99t happen = shortly after 2.0 :) Good work everyone! Best Jan -- > On 17 Oct 2015, at 21:20, Harald Kisch wrote: >=20 > Johs, thank you for testing the amazing features unlocked by ermouth. > Now it would be great to monk this up to the release of CouchDB 2.0. > This new feature sets are a great cntribution for the community and = all > couchappers. > I am very excited about the outcome of ermouth's work. He saw it, = figured > it out what to do, and did it. > Thank you for this ermouth. > +100 >=20 > On Sat, Oct 17, 2015 at 4:45 PM, Johs Ensby wrote: >=20 >> Thanks for your efforts, ermouth >>=20 >> I have been playing with it using the community AMI you put up adn it >> works just great. >> It is a big step forward for couchapps since it is not possible to >> use username, or role from userCtx in rewrite rules >> you can use the users IP address to firewall your system >> you can redirect from GET to PUT >> by going from a simple path, pick up username from userCtx, add = timestamp >> and other context info you have a lot to play with >> doing so by pointing to a _update function expands the possibilities >> further >> creating nested rules is really easy >> using regExp offers another host of possibilities >> since you can return a http code and body directly, you can skip = creating >> pages for common respons. A simple template function and the >> this.template[whatever] that is sitting in your ddoc will do in most = cases, >> especially having usrCtx available >>=20 >> What I did was to create a EC2 instannce, redirect traffic on port 80 >> directly to CouchDB 2, set up a few vhosts and their corresponding = design >> documents. >> I always set up a design document to the the API for my app or system = of >> apps and it feels akward to speak of a rewrite handler after this. >>=20 >> _rewrite concecptual upgrade #1 >> ************************************* >> At least we now have a router management system. >> It would be easy to implement your favourite router in the CouchDB >> _rewrite, making nice isomorphic sollutions >>=20 >> _rewrite concecptual upgrade #2 >> ************************************* >> I woud call my first experiment an API server. Inside a ddoc, yes. >> The simplicity is a bit hard to grasp. >> The power of this simplicity is even hard to grasp. >>=20 >> I hope there is someone that would pick up where ermouth left this = and >> push it through testing so it could be released with 2.0 >> It unlocks a lot of the hidden power of couchapps, and with the Pouch >> based tools Ddoc Lab and Inliner that ermouth has made for the site = builder >> and content people, this is a very low barrier of entry to CouchDB = for new >> developers. >>=20 >> Johs >>=20 >>=20 >>=20 >>=20 >>> On 16. okt. 2015, at 14.19, ermouth wrote: >>>=20 >>> Closing proposal off. >>>=20 >>> If someone wants to carry it on, current state is: >>>=20 >>>=20 >> = https://github.com/ermouth/couchdb-chttpd/commit/8e50451aec2b07f95b9115ddd= c9b33b512651026 >>>=20 >> = https://github.com/ermouth/couchdb-couch/commit/54b4324eeefe27431f5b42a892= 26b1ea63e17eb6 >>>=20 >> = https://github.com/ermouth/couchdb/commit/4d2d91ed67ed982ff2667cafa5c308e1= a95350bc >>>=20 >> = https://github.com/ermouth/couchdb-couch-mrview/commit/ae7ff262a8ace666891= d6c9af5386ed2d1910303 >>>=20 >>> It all works pretty fine and tested, but with own tests, since I was >> unable >>> to overcome CouchDB test set in reasonable time =E2=80=93 so no PR. >>>=20 >>> Current syntax example: >>>=20 >>> rewrites: function(req) { >>> // req is similar to req obj in list fn, but without .id, .info, = .uuid, >>> .form >>> return { >>> // path is mandatory >>> path:"/some/path?with=3Dquery&some=3Dparams", >>> // other fields are optional >>> headers:{/*headers go here*/}, >>> method:"POST", >>> code:404, >>> body:JSON.stringify([1,2,3]) >>> } >>> } >>>=20 >>> ermouth >>=20 >>=20 >=20 >=20 > --=20 >=20 > Dipl.-Inf. Harald R. Kisch >=20 > B=C3=BCro besetzt von Di - Do 9:00 Uhr bis 18:00 Uhr > Jahnstr. 3 > 80469 M=C3=BCnchen > Germany >=20 > Tel: +49 (0) 89 41 61 58 57-6 > Mobil DE: +49 (0) 176 56 58 58 38 >=20 > Skype: harald.kisch > Mail: haraldkisch@gmail.com --=20 Professional Support for Apache CouchDB: http://www.neighbourhood.ie/couchdb-support/