http://hychen.wuweig.org/blog/2013/08/11/pgrest-howto/