Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
#113 Allow options to specify the mimetype for a format
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcassel committed Jun 26, 2013
1 parent 2dc3cfb commit 13c6682
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/roxy/lib/routing-helper.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import module namespace req = "http://marklogic.com/roxy/request" at "/roxy/lib/

import module namespace u = "http://marklogic.com/roxy/util" at "/roxy/lib/util.xqy";

import module namespace c = "http://marklogic.com/roxy/config" at "/app/config/config.xqy";

declare namespace vh = "http://marklogic.com/roxy/view-helper";

declare option xdmp:mapping "false";
Expand Down Expand Up @@ -68,14 +70,18 @@ declare function rh:render-layout($layout as xs:string, $format as xs:string, $d
};
declare function rh:set-content-type($format)
{
if ($format eq "xml") then
xdmp:set-response-content-type("application/xml")
else if ($format eq "html") then
xdmp:set-response-content-type("text/html")
else if ($format eq "json") then
xdmp:set-response-content-type("application/json")
else if ($format eq "text") then
xdmp:set-response-content-type("text/plain")
else
xdmp:set-response-content-type($format)
let $type as xs:string? := $c:ROXY-OPTIONS/formats/format[@name = $format]/@type/fn:string(.)
return
if (fn:exists($type)) then
xdmp:set-response-content-type($type)
else if ($format eq "xml") then
xdmp:set-response-content-type("application/xml")
else if ($format eq "html") then
xdmp:set-response-content-type("text/html")
else if ($format eq "json") then
xdmp:set-response-content-type("application/json")
else if ($format eq "text") then
xdmp:set-response-content-type("text/plain")
else
xdmp:set-response-content-type($format)
};

0 comments on commit 13c6682

Please sign in to comment.