-
-
Save wrightlabs/421325 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'sinatra' | |
require 'spira' | |
require 'rack/linkeddata' | |
use Rack::LinkedData::ContentNegotiation, :default => 'text/turtle' | |
include RDF | |
# FIXME: why is this needed? | |
Spira.add_repository! :default, Repository.new | |
class Person | |
include Spira::Resource | |
property :name, :predicate => FOAF.name, :type => String | |
property :homepage, :predicate => FOAF.homepage | |
end | |
njh = Person.new( | |
RDF::URI('http://www.aelius.com/njh#me'), | |
:name => 'Nicholas Humfrey', | |
:homepage => URI('http://www.aelius.com/njh/') | |
) | |
get '/njh' do | |
njh | |
end | |
# Then try: | |
# | |
# curl -H 'Accept: text/turtle' http://127.0.0.1:4567/njh | |
# curl -H 'Accept: application/rdf+xml' http://127.0.0.1:4567/njh | |
# curl -H 'Accept: application/json' http://127.0.0.1:4567/njh | |
# | |
# or | |
# | |
# curl -H 'Accept: application/rdf+xml;q=0.1,text/plain' http://127.0.0.1:4567/njh | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment