forked from pramsey/pgsql-http
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp--1.3--1.4.sql
26 lines (22 loc) · 890 Bytes
/
http--1.3--1.4.sql
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
CREATE OR REPLACE FUNCTION http_list_curlopt ()
RETURNS TABLE(curlopt text, value text)
AS 'MODULE_PATHNAME', 'http_list_curlopt'
LANGUAGE 'c';
CREATE OR REPLACE FUNCTION urlencode(string BYTEA)
RETURNS TEXT
AS 'MODULE_PATHNAME'
LANGUAGE 'c'
IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION urlencode(data JSONB)
RETURNS TEXT
AS 'MODULE_PATHNAME'
LANGUAGE 'c'
IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION http_get(uri VARCHAR, data JSONB)
RETURNS http_response
AS $$ SELECT @extschema@.http(('GET', $1 || '?' || @extschema@.urlencode($2), NULL, NULL, NULL)::http_request) $$
LANGUAGE 'sql';
CREATE OR REPLACE FUNCTION http_post(uri VARCHAR, data JSONB)
RETURNS http_response
AS $$ SELECT @extschema@.http(('POST', $1, NULL, 'application/x-www-form-urlencoded', @extschema@.urlencode($2))::http_request) $$
LANGUAGE 'sql';