-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RESTXQ Multiple Path Annotations #3405
Comments
Is one spelling of each endpoint canonical? If so, why not handle the non-canonical variants with a 302 permanent redirect to the canonical endpoint? |
That could be a workaround. But I think there should no difference between the two styles of handling the Accept. For Accept headers to work correctly I’d need an additional copy for every Spelling * Accept or add a controller for it. Keeping it in 1 solution lessens the risk of going out of sync |
Hi @ahenket thanks for reporting. I thought I would remind myself of the intended behaviour that I set out in the initial RESTXQ paper. I found the following two parts that are relevant in section 4.3.1:
Whilst having multiple $ curl -X GET -I http://localhost:4059/exist/restxq/api/test1
HTTP/1.1 405 Method Not Allowed
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html;charset=iso-8859-1
Content-Length: 576
Server: FDB(1.0.0-SNAPSHOT) $ curl -X GET -I http://localhost:4059/exist/restxq/api/Test1
HTTP/1.1 200 OK
Date: Fri, 08 May 2020 12:00:41 GMT
Content-Type: application/xml; charset=UTF-8
Vary: Accept-Encoding, User-Agent
Transfer-Encoding: chunked
Server: FDB(1.0.0-SNAPSHOT) IMHO it seems like having multiple path annotations should raise the error We could however think about improving on this behaviour of RESTXQ 1.0 in say RESTXQ 2.0 if people are interested in creating a 2.0 spec?
That's not very helpful is it! Both By running For your Test2 example, if I remove the multiple path annotations as we know that isn't supported, I get something like this: declare
%rest:GET
%rest:path("/api/Test2")
%rest:produces("application/json", "text/json")
%output:media-type("text/json")
%output:method("json")
%exist:serialize("json-ignore-whitespace-text-nodes=yes")
function testapi:getTestJson() {
<serverinfo>
<getTestJson>true</getTestJson>
<database version="{system:get-version()}"/>
</serverinfo>
};
declare
%rest:GET
%rest:path("/api/Test2")
%rest:produces("application/xml", "text/xml")
%output:media-type("text/xml")
%output:method("xml")
function testapi:getTestXml() {
<serverinfo>
<getTestXml>true</getTestXml>
<database version="{system:get-version()}"/>
</serverinfo>
}; And <rest:resource-function xmlns:rest="http://exquery.org/ns/restxq" xquery-uri="/db/testapi.xqm">
<rest:identity namespace="http://testapi" local-name="getTestJson" arity="0"/>
<rest:annotations>
<rest:GET/>
<rest:produces>
<rest:internet-media-type>application/json</rest:internet-media-type>
<rest:internet-media-type>text/json</rest:internet-media-type>
</rest:produces>
<rest:path specificity-metric="7">
<rest:segment>api</rest:segment>
<rest:segment>Test2</rest:segment>
</rest:path>
<output:media-type xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization">text/json</output:media-type>
<output:method xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization">json</output:method>
</rest:annotations>
</rest:resource-function>
<rest:resource-function xmlns:rest="http://exquery.org/ns/restxq" xquery-uri="/db/testapi.xqm">
<rest:identity namespace="http://testapi" local-name="getTestXml" arity="0"/>
<rest:annotations>
<rest:GET/>
<rest:produces>
<rest:internet-media-type>application/xml</rest:internet-media-type>
<rest:internet-media-type>text/xml</rest:internet-media-type>
</rest:produces>
<rest:path specificity-metric="7">
<rest:segment>api</rest:segment>
<rest:segment>Test2</rest:segment>
</rest:path>
<output:media-type xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization">text/xml</output:media-type>
<output:method xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization">xml</output:method>
</rest:annotations>
</rest:resource-function> We can see that we can call both of these resource functions using curl:
So I think the problem is not with the I think it would be nice though if multiple |
Describe the bug
I got around to testing multiple
%rest:path
annotations to support my need for different capitalizations on the same path. Results:Accept
header to produce output, it will support multiple%rest:path
annotations that differ only on capitalization.Accept
type, you will only get HTTP 405 once you add multiple%rest:path
annotations that differ only in capitalization.Tester code attached.
api/test1
andapi/Test1
will work.api/test2
norapi/Test2
works, unless you remove the lower-case or upper-case paths.Expected behavior
I expect both styles to work the same. E.g.
api/Test2
should be sent totestapi:getTestJson()
.To Reproduce
Add code below to a location in eXist-db where RestXQ is triggered. Make sure it has execution permissions for guest.
Go to postman or browser and run:
api/test1
orapi/Test1
(both will work)api/test2
orapi/Test2
(don't work, unless you remove the lower-case or upper-case paths)Context (please always complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: