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

xdmp:set-response-code does not seem to work with ML 8.0-3 #511

Closed
heelix opened this issue Sep 9, 2015 · 4 comments
Closed

xdmp:set-response-code does not seem to work with ML 8.0-3 #511

heelix opened this issue Sep 9, 2015 · 4 comments
Labels
Milestone

Comments

@heelix
Copy link

heelix commented Sep 9, 2015

Seems like xdmp:set-response-code does not do anything anymore. Exceptions (real ones) seem to get forwarded, but if I try to manually set a response code, it still comes back as 200/OK.

declare
%roxy:params("")
function cs:delete(
$context as map:map,
$params as map:map
) as document-node()?
{
map:put($context, "output-types", "application/xml"),
xdmp:set-response-code(501, "Not Implemented"),
document { "DELETE called" }
};

I see the docs for the ML REST client show something like this now.

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

declare function example:put(
$context as map:map,
$params as map:map,
$input as document-node()*
) as document-node()?
{
...
map:put($context, "output-status", (201, "Created"));
};

@dmcassel
Copy link
Collaborator

dmcassel commented Sep 9, 2015

Are you saying that the output-status part does work but xdmp:set-response-code() does not?

@heelix
Copy link
Author

heelix commented Sep 9, 2015

(edit: sorta). You see 'DELETE called', with 200/OK rather than the 501/Not Implemented.

The snippet from below was from the ML REST docs, for how they seem to be setting the response code/message.

declare
%roxy:params("")
function cs:delete(
$context as map:map,
$params as map:map
) as document-node()?
{
map:put($context, "output-types", "application/xml"),
map:put($context, "output-status", (502, "All Busted")),
xdmp:set-response-code(501, "Not Implemented"),
document { "DELETE called" }
};

Will output 502/All Busted.

@dmcassel
Copy link
Collaborator

dmcassel commented Sep 9, 2015

Okay. Looks like our extension template needs an update.

@dmcassel dmcassel added the bug label Sep 9, 2015
dmcassel added a commit to dmcassel/roxy that referenced this issue Sep 10, 2015
Response codes should be set in $context, not with xdmp:set-response-code().
http://docs.marklogic.com/guide/rest-dev/extensions#id_31884
@heelix
Copy link
Author

heelix commented Sep 10, 2015

That is enough to close the issue with ML8.0-3. Probably want to have something more with fn:error() later on rather than xdmp:set-response-code... but... xdmp:set-response-code will indeed set the code/message.

@heelix heelix closed this as completed Sep 10, 2015
dmcassel added a commit to dmcassel/roxy that referenced this issue Sep 11, 2015
grtjn added a commit that referenced this issue Sep 11, 2015
#511 corrected extension template
@grtjn grtjn modified the milestone: 1.7.3 Sep 17, 2015
grtjn pushed a commit to grtjn/roxy that referenced this issue Jan 28, 2016
Response codes should be set in $context, not with xdmp:set-response-code().
http://docs.marklogic.com/guide/rest-dev/extensions#id_31884
grtjn pushed a commit to grtjn/roxy that referenced this issue Jan 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants