Created
September 22, 2016 03:06
-
-
Save baskaufs/00f471b905ae9b862677fedf9f047bcb to your computer and use it in GitHub Desktop.
restxq module with content negotiation that fails with a browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module namespace page = 'http://basex.org/modules/web-page'; | |
declare | |
%rest:path("/{$id}") | |
%rest:GET | |
%rest:produces("text/turtle") | |
function page:turtle($id) | |
{ | |
<rest:response> | |
<output:serialization-parameters> | |
<output:media-type value='text/turtle'/> | |
</output:serialization-parameters> | |
</rest:response>, | |
'<http://ex.org/my><http://ex.org/example>"Turtle text".' | |
}; | |
declare | |
%rest:path("/{$id}") | |
%rest:GET | |
%rest:produces("application/rdf+xml") | |
function page:xml($id) | |
{ | |
<rest:response> | |
<output:serialization-parameters> | |
<output:media-type value='application/rdf+xml'/> | |
</output:serialization-parameters> | |
</rest:response>, | |
<example>this is RDF/XML</example> | |
}; | |
declare | |
%rest:path("/{$id}") | |
%rest:GET | |
%rest:produces("application/json") | |
function page:json-ld($id) | |
{ | |
<rest:response> | |
<output:serialization-parameters> | |
<output:media-type value='application/json'/> | |
</output:serialization-parameters> | |
</rest:response>, | |
'{"this":"is RDF/JSON"}' | |
}; | |
declare | |
%rest:path("/{$id}") | |
%rest:GET | |
%rest:produces("text/html","application/xhtml+xml") | |
function page:html($id) | |
{ | |
<rest:response> | |
<output:serialization-parameters> | |
<output:media-type value='text/html'/> | |
</output:serialization-parameters> | |
</rest:response>, | |
<html><body>this is a web page</body></html> | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment