MarkLogic Server 11.0 Product Documentation
rest:process-request

rest:process-request(
   $request as element(rest:request)
) as map:map

Summary

This function is used in the endpoint main module to parse the incoming request against the options. It returns a map that contains all of the parameters as typed values. Processing the request also checks all of the associated conditions and will raise an error if any condition is not met.

If the request is processed successfully, then all of the conditions have been met and the returned map contains all of the parameters. If not, an error occurs.

Parameters
request The request to be processed into a map.

Example

  xquery version "1.0-ml"; 
 
  import module namespace rest="http://marklogic.com/appservices/rest"
      at "/MarkLogic/appservices/utils/rest.xqy";

  declare default function namespace "http://www.w3.org/2005/xpath-functions";

  declare option xdmp:mapping "false";

  let $request :=
    <rest:request uri="^/endpoint/(.+)/(\d+)$" endpoint="/endpoint.xqy">
      <rest:uri-param name="play">$1.xml</rest:uri-param>
      <rest:uri-param name="act" as="decimal" 
	      optional="true">$2</rest:uri-param>
    </rest:request>
 
  let $map  := rest:process-request($request) 
  let $play := map:get($map, "play") 
  let $num  := map:get($map, "act") 

  return  
    if (empty($num))
    then
      fn:doc($play)
    else
      fn:doc($play)/PLAY/ACT[$num]
  
  (: The rest:process-request returns a map from $request that contains the 
     keys 'play' and 'act', which are use to return either the contents of 
     an entire play or a specific act in the play. :)
    
Powered by MarkLogic Server | Terms of Use | Privacy Policy