@@ -85,58 +85,64 @@ declare function debug:dump-env()
8585
8686declare function debug:dump-env ($name as xs:string?)
8787{
88- let $request-path := xdmp:get-request-path ()
89- let $request-path :=
90- if ($request-path = '/MarkLogic/rest-api/endpoints/resource-service-query.xqy' ) then
91- let $params := fn:string-join (
92- for $f in xdmp:get-request-field-names ()[fn:starts-with (., "rs:" )]
93- let $value := xdmp:get-request-field ($f)
88+ if (debug:on ()) then
89+ let $request-path := xdmp:get-request-path ()
90+ let $request-path :=
91+ if ($request-path = '/MarkLogic/rest-api/endpoints/resource-service-query.xqy' ) then
92+ let $params := fn:string-join (
93+ for $f in xdmp:get-request-field-names ()[fn:starts-with (., "rs:" )]
94+ let $value := xdmp:get-request-field ($f)
95+ return
96+ $f || "=" || fn:string-join ($value, ", " ),
97+ "& " )
9498 return
95- $f || "=" || fn:string-join ($value, ", " ),
96- "& " )
97- return
98- "/v1/resources/" || xdmp:get-request-field ("name" ) || "?" || $params
99- else
100- $request-path
101- return
102- debug:log ((
103- "" ,
104- "" ,
105- "################################################################" ,
106- "REQUEST DETAILS:" ,
107- "" ,
108- if ($name) then
109- (
110- " **" || $name || "**" ,
111- ""
112- )
113- else (),
114- " [" || xdmp:get-request-method () || "] " || $request-path,
115- "" ,
116- " [Headers]" ,
117- for $h in xdmp:get-request-header-names ()
118- return
119- " " || $h || " => " || xdmp:get-request-header ($h),
120- "" ,
121- " [Request Params]" ,
122- for $p in xdmp:get-request-field-names ()[fn:not (fn:starts-with (., "rs:" ))]
123- return
124- " " || $p || " => " || fn:string-join (xdmp:get-request-field ($p), ", " ),
125- let $body := xdmp:get-request-body ()
126- return
127- if (fn:exists ($body)) then
128- (
129- "" ,
130- " [Body]" ,
131- " " || xdmp:describe ($body, (), ())
132- )
99+ "/v1/resources/" || xdmp:get-request-field ("name" ) || "?" || $params
100+ else
101+ $request-path
102+ return
103+ debug:log ((
104+ "" ,
105+ "" ,
106+ "################################################################" ,
107+ "REQUEST DETAILS:" ,
108+ "" ,
109+ if ($name) then
110+ (
111+ " **" || $name || "**" ,
112+ ""
113+ )
133114 else (),
134- "" ,
135- "################################################################" ,
136- "" ,
137- "" ,
138- ""
139- ))
115+ " [" || xdmp:get-request-method () || "] " || $request-path,
116+ "" ,
117+ " [Headers]" ,
118+ for $h in xdmp:get-request-header-names ()
119+ return
120+ " " || $h || " => " || xdmp:get-request-header ($h),
121+ "" ,
122+ " [Request Params]" ,
123+ for $p in xdmp:get-request-field-names ()[fn:not (fn:starts-with (., "rs:" ))]
124+ return
125+ " " || $p || " => " || fn:string-join (xdmp:get-request-field ($p), ", " ),
126+ let $body :=
127+ try {
128+ xdmp:get-request-body ()
129+ }
130+ catch ($ex) {()}
131+ return
132+ if (fn:exists ($body)) then
133+ (
134+ "" ,
135+ " [Body]" ,
136+ " " || xdmp:describe ($body, (), ())
137+ )
138+ else (),
139+ "" ,
140+ "################################################################" ,
141+ "" ,
142+ "" ,
143+ ""
144+ ))
145+ else ()
140146};
141147
142148declare function debug:dump-map ($m as map:map)
0 commit comments