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:


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:media-type value='application/zip'/>
</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')

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