Skip to content

Instantly share code, notes, and snippets.

@tternquist
Created December 22, 2016 23:01
Show Gist options
  • Save tternquist/685e58a0df46ffe525be5c320654fbcd to your computer and use it in GitHub Desktop.
Save tternquist/685e58a0df46ffe525be5c320654fbcd to your computer and use it in GitHub Desktop.
Gzip encoding for MarkLogic REST extension
let $result := element result {"Hi"}
return
if(fn:contains(xdmp:get-request-header("Accept-encoding"),"gzip"))
then
(
document {
xdmp:gzip(
text { $result } )
},
xdmp:add-response-header("Content-encoding", "gzip")
)
else document {$result}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment