eXist 2.2RC1

I have a zip file contained within the database.  How Can I get it downloading through RestXQ?

 

I have started with the following:

 


declare
    %rest:GET
    %rest:path("/get-edd/{$id}")
function eim:get-edd($id as xs:string) {
   
let $filename := $id || '.zip'
   
let $path := $config:data-root || '/CDXF_EIM/edd/' || $filename
   
let $available := util:binary-doc-available($path)
   
return (<rest:response>
    
<output:serialization-parameters>
      
<output:media-type value='application/zip'/>
    
</output:serialization-parameters>
  
</rest:response>, util:binary-doc($path))
};

 

 

 

I had the following working in a XQuery script file:

 

let $zip := compression:zip((xs:anyURI($new-collection)), false())
let $stored := xmldb:store($edd-dir, $new-dir-name || '.zip', $zip, 'application/zip')
let $response := response:stream-binary($zip, "media-type=application/zip",
                
$new-dir-name || '.zip')
return
   
$response

 What do I need to do in RestXQ to get the desired result?

 .