Created
July 31, 2011 03:44
-
-
Save AlBaker/1116356 to your computer and use it in GitHub Desktop.
Linked Ratpack Sample
This file contains hidden or 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
set 'port', 4999 | |
// All three methods (RDFBuilder closure, construct, resolve) return | |
// Jena models and can be further processed with Groovy SPARQL's Sparql class | |
// link(String endpoint) returns the Sparql endpoint or you can instantiate new | |
// ones. Jena+ ARQ will be on the classpath | |
get("/") { | |
setHeader("Content-Type", "application/rdf+xml") | |
rdf.xml { | |
defaultNamespace "http://localhost:4999/test" | |
namespace foaf:"http://xmlns.com/foaf/0.1" | |
subject("#clarkkent") { | |
property "foaf:gender":"male" | |
property "foaf:title":"Mr" | |
property "foaf:givenname":"Clark" | |
property "foaf:family_name":"Kent" | |
} | |
};return null; // using the builder already sends output | |
// and lets you customize the serialization format | |
} | |
get("/groovy") { | |
link("http://dbpedia.org/sparql").construct(""" | |
CONSTRUCT { | |
<http://dbpedia.org/resource/Groovy_%28programming_language%29> <http://dbpedia.org/ontology/abstract> ?b | |
} wHERE { | |
<http://dbpedia.org/resource/Groovy_%28programming_language%29> <http://dbpedia.org/ontology/abstract> ?b | |
} | |
""") | |
} | |
get("/tim") { | |
resolve('http://www.w3.org/People/Berners-Lee/card') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment