Created
October 20, 2015 12:09
-
-
Save cuu508/082a4c86aebfa4a832a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~ ^/(\w\w\w\w\w\w\w\w-\w\w\w\w-\w\w\w\w-\w\w\w\w-\w\w\w\w\w\w\w\w\w\w\w\w)/?$ { | |
add_header Content-Type text/plain; | |
postgres_pass database; | |
postgres_output value; | |
postgres_escape $ip $remote_addr; | |
postgres_escape $agent =$http_user_agent; | |
postgres_escape $body =$request_body; | |
postgres_query " | |
WITH t AS ( | |
UPDATE api_check | |
SET last_ping=now() | |
WHERE code='$1' | |
RETURNING id, last_ping | |
) | |
INSERT INTO api_ping | |
(created, remote_addr, method, ua, body, owner_id, scheme) | |
SELECT | |
last_ping, $ip, '$request_method', $agent, $body, id, '$scheme' | |
FROM t | |
RETURNING 'OK' | |
"; | |
postgres_rewrite no_changes 400; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment