FRiCKLE / ngx_postgres

upstream module that allows nginx to communicate directly with PostgreSQL database.
http://labs.frickle.com/nginx_ngx_postgres/
BSD 2-Clause "Simplified" License
545 stars 122 forks source link

Better example of retrieving GET params #7

Closed docyes closed 13 years ago

docyes commented 13 years ago

I spent some time reading and hacking out some examples and have been unable to retrieve GET params from the query string. None of the examples address this as the one specific example has it in the path of the url.

agentzh commented 13 years ago

Here's a small example:

location /cat {
    set_unescape_uri $name $arg_name;   # this requires ngx_set_misc
    set_quote_pgsql_str $name;   # ditto
    postgres_query 'select * from cats where name = $name';
    postgres_pass my_pg_backend;
}

Have fun :) -agentzh

agentzh commented 13 years ago

I've added this sample to README and this ticket can be closed.

Thanks for the suggestion :)

-agentzh