Allow returning XML from RPCs
This commit is contained in:
committed by
Steve Chavez
parent
a8477b7822
commit
d2aa50be52
@@ -970,6 +970,37 @@ spec actualPgVersion =
|
||||
, matchHeaders = ["Content-Type" <:> "text/plain; charset=utf-8"]
|
||||
}
|
||||
|
||||
it "can get raw xml output with Accept: text/xml" $
|
||||
request methodGet "/rpc/return_scalar_xml" (acceptHdrs "text/xml") ""
|
||||
`shouldRespondWith`
|
||||
"<my-xml-tag/>"
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = ["Content-Type" <:> "text/xml; charset=utf-8"]
|
||||
}
|
||||
|
||||
it "can get raw xml output with Accept: text/xml" $
|
||||
request methodGet "/rpc/welcome.xml" (acceptHdrs "text/xml") ""
|
||||
`shouldRespondWith`
|
||||
"<html>\n <head>\n <title>PostgREST</title>\n </head>\n <body>\n <h1>Welcome to PostgREST</h1>\n </body>\n</html>"
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = ["Content-Type" <:> "text/xml; charset=utf-8"]
|
||||
}
|
||||
|
||||
it "should fail with function returning text and Accept: text/xml" $
|
||||
request methodGet "/rpc/welcome" (acceptHdrs "text/xml") ""
|
||||
`shouldRespondWith`
|
||||
[json|
|
||||
{
|
||||
"hint":"No function matches the given name and argument types. You might need to add explicit type casts.",
|
||||
"details":null,
|
||||
"code":"42883",
|
||||
"message":"function xmlagg(text) does not exist"
|
||||
}
|
||||
|]
|
||||
{ matchStatus = 406
|
||||
, matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"]
|
||||
}
|
||||
|
||||
context "Proc that returns set of scalars" $
|
||||
it "can query without selecting column" $
|
||||
request methodGet "/rpc/welcome_twice"
|
||||
|
||||
Vendored
+18
@@ -2553,3 +2553,21 @@ create table plate_plan_step (
|
||||
FOREIGN KEY(to_well_id)
|
||||
REFERENCES well(well_id)
|
||||
);
|
||||
|
||||
CREATE FUNCTION test.return_scalar_xml() RETURNS pg_catalog.xml
|
||||
LANGUAGE sql AS $$
|
||||
SELECT '<my-xml-tag/>'::pg_catalog.xml
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION "welcome.xml"() RETURNS pg_catalog.xml
|
||||
LANGUAGE sql AS $_$
|
||||
select $$
|
||||
<html>
|
||||
<head>
|
||||
<title>PostgREST</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to PostgREST</h1>
|
||||
</body>
|
||||
</html>$$::pg_catalog.xml;
|
||||
$_$;
|
||||
|
||||
Reference in New Issue
Block a user