swirrl / contentnegotiation Goto Github PK
View Code? Open in Web Editor NEWExample code for doing HTTP content negotiation for Linked Data in Ruby on Rails
Home Page: http://www.swirrl.com
License: MIT License
Example code for doing HTTP content negotiation for Linked Data in Ruby on Rails
Home Page: http://www.swirrl.com
License: MIT License
Ruby on Rails Linked Data content negotiation skeleton code. ============================================================ This is a complete (though very simple!) Ruby on Rails application (version 2.3.2). The only non-standard files are the following: - app/controllers/resources_controller.rb - This is the file that actually does the content negotiation, using the standard Rails 'respond_to' method. - config/environment.rb - includes the definition of the application/rdf+xml MIME type and maps it to the .rdf extension. - config/routes.rb - maps URLs of the form <domain>/resources/<id> to the 'show' action of 'resources_controller' - app/views/resources/show.erb - to generate the HTML representation of a resource (dummy code only) - app/views/resources/show.rxml - to generate the RDF representaiton of a resource (dummy code only) This example assumes the following approach to URIs: http://<my domain>/resources/<resource_name> - URI for the resource http://<my domain>/resources/<resource_name>.html - HTML description of the resource http://<my domain>/resources/<resource_name>.rdf - RDF description of the resource To run the application you will need to set up an empty MySQL database called 'conneg_development' with user 'root' and password 'admin' or of course adapt the file config/database.yml to match your own choices for database name and account details. To check if it is working: -------------------------- 1. run the app in development mode 2. In your browser, enter the url http://localhost:3000/resources/test1 3. You should be redirected to http://localhost:3000/resources/test1.html and see the text "HTML description of the resource here." 4. In your browser, enter the url http://localhost:3000/resources/test1.rdf - you should see some valid RDF 5. From the command line (on Unix like systems) enter: curl -v -H "Accept: application/rdf+xml" http://localhost:3000/resources/test1 You should get a response like this: > GET /resources/test1 HTTP/1.1 > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3 > Host: localhost:3000 > Accept: application/rdf+xml > < HTTP/1.1 303 See Other < Connection: close < Date: Mon, 06 Jul 2009 10:05:18 GMT < X-Runtime: 3 < Location: http://localhost:3000/resources/test1.rdf < Content-Type: application/rdf+xml; charset=utf-8 < Cache-Control: no-cache < Content-Length: 107 < Any questions, contact me at [email protected] Bill Roberts, 06 July, 2009. The code in this example is released under the MIT license http://www.opensource.org/licenses/mit-license.php Copyright (c) 2009, Swirrl IT Ltd., http://www.swirrl.com
When I go command line (on Unix like systems) enter:
curl -v -H "Accept: ap://0.0.0.0:3000/projetos/unix
< HTTP/1.1 303 See OtherGET /projetos/unix HTTP/1.1
User-Agent: curl/7.29.0
Host: 0.0.0.0:3000
Accept: application/rdf+xml
But not redirect ,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.