Hi, Zach:

Modifying the rewriter for a REST server isn't supported.  Can you explain what 
you hope to accomplish by modifying the REST rewriter?   There may be a better 
way -- possibly using resource service extensions?

    http://docs.marklogic.com/guide/rest-dev/extensions


Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of Dunlap, Zachariah 
[[email protected]]
Sent: Thursday, August 01, 2013 7:04 AM
To: [email protected]
Subject: [MarkLogic Dev General] Modifying rewriter.xqy

I’d like to make some modifications to rewriter.xqy found at: 
/MarkLogic/rest-api/rewriter.xqy.

I’ve copied rewrite.xqy and changed it as follows:

xquery version "1.0-ml";

(: Copyright 2011-2013 MarkLogic Corporation.  All Rights Reserved. :)
import module namespace amped-common = 
"http://marklogic.com/appservices/util-amped";
    at "/MarkLogic/appservices/utils/common-amped.xqy";

amped-common:appservices-check-license-valid();

import module namespace rest = "http://marklogic.com/appservices/rest";
    at "/MarkLogic/appservices/utils/rest.xqy";

import module namespace conf = "http://marklogic.com/rest-api/endpoints/config";
    at "/MarkLogic/rest-api/endpoints/config.xqy";

declare default function namespace "http://www.w3.org/2005/xpath-functions";;
declare option xdmp:mapping "false";

let $uri  := xdmp:get-request-url()
let $customuri := if (fn:starts-with($uri, "/search?q=")) then fn:replace($uri, 
"^/search\?q=", "/v1/search?options=appl&q=")
    else if (fn:starts-with($uri, "/item/")) then fn:replace($uri, "/item/", 
"/v1/documents?format=xml&uri=/content/")
    else $uri

return (
        conf:rewrite(xdmp:get-request-method(), $customuri, 
xdmp:get-request-path()),
        $customuri
        )[1]

Unfortunately, it seems that anything after the ? in my fn:replace statement is 
getting dropped. I gather this is because there is something in config.xqy or 
elsewhere that is saying the ? should be the end of the line, but I can’t 
locate it. I’ve tried URL encoding the ? but that doesn’t work either.

If anyone has any suggestions on how I can get past this hurdle or can suggest 
a better way for me to achieve what I’m trying to do, I welcome your input.

Thanks,

Zach

The information contained in this communication is intended for the use
of the designated recipients named above. If the reader of this
communication is not the intended recipient, you are hereby notified
that you have received this communication in error, and that any review,
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please
notify The Associated Press immediately by telephone at +1-212-621-1898
and delete this email. Thank you.
[IP_US_DISC]


msk dccc60c6d2c3a6438f0cf467d9a4938
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to