Skip to content
PostgRESTPublic

About

Nginx Gateway to Postgres

Resources

Stars

0 stars

Watchers

3 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

Motorpg (Work in Progress)

An Nginx module that serves as a gateway to Postgres.

Directives

pg_func <func_name> [args] ...;

default: none
context: location

Ran a postgres function taking any number of nginx complex values as arguments.

Examples

Having:

create or replace function greetings(firstname text, lastname text) returns text as $$
  select 'Greetings ' || firstname || ' ' || lastname;
$$ language sql;
location /greetings {
    pg_func greetings $arg_firstname $arg_lastname;
}

You can request:

curl 'localhost:8080/greetings?firstname=Marcus&lastname=Aurelius'
Greetings Marcus Aurelius

Installation

git clone https://github.com/PostgREST/motorpg

cd /path/to/nginx/source
./configure --with-compat --add-dynamic-module=/path/to/motorpg

Development

Nix is required for development. The go inside nix-shell to have all dependencies ready.

  • For compiling:
make
  • For starting a local nginx with a local postgres:
with-pg-16 make start
  • For hot reloading:
with-pg-16 make watch
  • For running tests:
with-pg-16 make test
  • Clean object files:
make clean

Anti-features

  • No inline SQL in directives
  • No specifying postgres connection details on the nginx config. Taking a lesson learned from PostgREST, we will only rely on a config file in .ini format for this and perhaps env vars.

About

Nginx Gateway to Postgres

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages