-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
44 lines (36 loc) · 1.43 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
worker_processes 8;
events {}
http {
upstream database {
postgres_server 127.0.0.1 dbname=itemdb user=itemdbuser password=myPassword;
}
server {
listen 8080;
server_name localhost;
location /items {
postgres_pass database;
rds_json on;
postgres_query HEAD GET "SELECT '/items/' || itemid AS detailsuri, itemid, itemheadline FROM items";
postgres_escape $itemheadline $arg_itemheadline;
postgres_escape $itemdescription $arg_itemdescription;
postgres_query
POST "INSERT INTO items (itemheadline, itemdescription) VALUES($itemheadline, $itemdescription) RETURNING *";
postgres_rewrite POST changes 201;
}
location ~ /items/(?<id>\d+) {
postgres_pass database;
rds_json on;
postgres_escape $escaped_id $id;
postgres_query HEAD GET "SELECT * FROM items WHERE itemid=$escaped_id";
postgres_rewrite HEAD GET no_rows 410;
postgres_escape $itemheadline $arg_itemheadline;
postgres_escape $itemdescription $arg_itemdescription;
postgres_query
PUT "UPDATE items SET itemheadline=$itemheadline, itemdescription=$itemdescription WHERE itemid=$escaped_id RETURNING *";
postgres_rewrite PUT no_changes 410;
postgres_query DELETE "DELETE FROM items WHERE itemid=$escaped_id";
postgres_rewrite DELETE no_changes 410;
postgres_rewrite DELETE changes 204;
}
}
}