An Nginx module that serves as a gateway to Postgres.
pg_func <func_name> [args] ...;
default: none
context: location
Ran a postgres function taking any number of nginx complex values as arguments.
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 Aureliusgit clone https://github.com/PostgREST/motorpg
cd /path/to/nginx/source
./configure --with-compat --add-dynamic-module=/path/to/motorpg
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
- 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.