soca icon indicating copy to clipboard operation
soca copied to clipboard

vhost/rewrite support?

Open max-mapper opened this issue 14 years ago • 6 comments

there doesn't seem to be a way to include rewrites through soca yet. is this correct?

max-mapper avatar Sep 28 '10 07:09 max-mapper

Yes, not yet. Rewrites should be easy though since they're part of the DB - vhost's might be a little harder, but im willing to give it a shot.

quirkey avatar Sep 29 '10 02:09 quirkey

ok awesome, I wasn't sure if I was missing something

for reference: python couchapp just has a root level rewrite.json that turns into the array of rewrites on your design doc.

for vhosts you would require server admin credentials and use the _config api.... but that's easy enough to do manually that you wouldn't necessarily need tooling for it (unless you consider a more automated vhost config a big convenience win)

max-mapper avatar Sep 29 '10 03:09 max-mapper

i got deeper into rewrites over the last few days...

http://github.com/maxogden/couchappspora/blob/master/rewrites.json

the rewrites at the bottom are the key for vhosts... since it tricks $.couch into thinking you're at the root of a couchdb instance

http://wiki.couchapp.org/page/faq has some info under the 'How do I use $.couch.app() behind a vhost?' section

max-mapper avatar Oct 01 '10 18:10 max-mapper

Rewrite rules can now be added in the rewrites.js file.

http://github.com/quirkey/soca/commit/9cbb2a545dd2473df89708edd8425d094cc27eba http://github.com/quirkey/soca/commit/925472b2d737c2357e237ace8286e139884a64d4

I think about renaming the file into rewrites.json (couchapp uses the same filename) but config.js has also .js and not .json extension.

I thought about how to store the vhost setting: putting it into config.js vs creating a soca command. Any thoughts on this?

rmetzler avatar Nov 03 '10 00:11 rmetzler

ooh awesome.

keeping it in config.js makes sense, as you need admin rights in order to interact with the config api

max-mapper avatar Nov 03 '10 01:11 max-mapper

I know, this is awesome. Thanks @rmetzler!

I'm realizing that maybe it makes sense to add a config option for mapping JSON instead of just directories. That way you could get rid of the need for a special filename for rewrites and just make it in config.js:

    {
        "mapJSON": {
            "rewrites.js": "rewrites"
        },
        ....
    }

Also re:vhosts - I think it makes sense to make it a seperate command, but also be part of the config/push process. Well have to split it by env like:

   "vhosts": {
     "default": null,
     "production": "soca.quirkey.com"
   }

What do you guys think?

quirkey avatar Nov 03 '10 02:11 quirkey