Created
February 25, 2017 17:12
-
-
Save apb2006/538f3feb6dd50789c4c618115b3dce61 to your computer and use it in GitHub Desktop.
restxq returning json with cors header
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
(:~ | |
: JSON test apb feb 2017 | |
:) | |
module namespace page = 'json-test'; | |
(: test data :) | |
declare variable $page:data:=<json objects="json _"> | |
<total type="number">15</total> | |
<entity>app</entity> | |
<items type="array"> | |
<_> | |
<name type="string">abide</name> | |
<uri type="string">/abide</uri> | |
<description type="string">todo this</description> | |
</_> | |
</items> | |
</json> | |
; | |
(:~ CORS header :) | |
declare function page:headers(){ | |
<restxq:response> | |
<http:response> | |
<http:header name="Access-Control-Allow-Origin" value="*"/> | |
</http:response> | |
</restxq:response> | |
}; | |
declare %rest:path("/json") | |
%output:method("json") | |
function page:json(){ | |
(page:headers(), | |
$page:data | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment