This repository has been archived by the owner on Mar 16, 2022. It is now read-only.
/
rest-ext.sample.xqy
70 lines (63 loc) · 1.61 KB
/
rest-ext.sample.xqy
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
xquery version "1.0-ml";
module namespace yourNSAlias = "http://marklogic.com/rest-api/resource/extension";
declare namespace roxy = "http://marklogic.com/roxy";
(:
: To add parameters to the functions, specify them in the params annotations.
: Example
: declare %roxy:params("uri=xs:string", "priority=xs:int") yourNSAlias:get(...)
: This means that the get function will take two parameters, a string and an int.
:)
(:
:)
declare
%roxy:params("")
function yourNSAlias:get(
$context as map:map,
$params as map:map
) as document-node()*
{
map:put($context, "output-types", "application/xml"),
xdmp:set-response-code(200, "OK"),
document { "GET called on the ext service extension" }
};
(:
:)
declare
%roxy:params("")
function yourNSAlias:put(
$context as map:map,
$params as map:map,
$input as document-node()*
) as document-node()?
{
map:put($context, "output-types", "application/xml"),
xdmp:set-response-code(200, "OK"),
document { "PUT called on the ext service extension" }
};
(:
:)
declare
%roxy:params("")
function yourNSAlias:post(
$context as map:map,
$params as map:map,
$input as document-node()*
) as document-node()*
{
map:put($context, "output-types", "application/xml"),
xdmp:set-response-code(200, "OK"),
document { "POST called on the ext service extension" }
};
(:
:)
declare
%roxy:params("")
function yourNSAlias:delete(
$context as map:map,
$params as map:map
) as document-node()?
{
map:put($context, "output-types", "application/xml"),
xdmp:set-response-code(200, "OK"),
document { "DELETE called on the ext service extension" }
};