Restkit version 1.2 introduced a WSGI proxy extension written by gawel .This extension proxy WSGI requests to a remote server.
Here is a quick example. You can read full post here .
We will do here a simple proxy for CouchDB. We use webob and gunicorn to launch it:
from webob import Request
from restkit.pool import ConnectionPool
from restkit.ext.wsgi_proxy import HostProxy
pool = ConnectionPool(max_connections=10)
proxy = HostProxy("http://127.0.0.1:5984", pool=pool)
def application(environ, start_response):
req = Request(environ)
# do smth like adding oauth headers ..
resp = req.get_response(proxy)
# rewrite response
# do auth ...
return resp(environ, start_response)
And then launch your application:
gunicorn -w 12 couchdbproxy::application
And access to your couchdb at http://127.0.0.1:8000 .