Skip to content

Scopes

dscape edited this page Mar 4, 2011 · 1 revision

Scopes

Scopes allow you to reuse your constraints for multiple routes:

 Request       : GET /user/admin
 routes.xml    : <routes>
                   <scope>
                     <constraints>
                       <id type="string"/>
                     </constraints>
                     <lambda>
                       xdmp:get-current-user() = $id
                     </lamda>
                     <put path="user/:id">
                       <to> user#put </to>
                     </put>
                     <get path="user/:id">
                       <to> user#get </to>
                     </get>
                   </scope>
                 </routes>
 Dispatches to : /resource/user.xqy?action=get&id=admin
Something went wrong with that request. Please try again.