- From: Gregg Kellogg <gregg@greggkellogg.net>
- Date: Thu, 13 Mar 2014 18:52:29 -0700
- To: cr <_@whats-your.name>
- Cc: public-rdf-ruby@w3.org
On Mar 10, 2014, at 8:27 PM, cr <_@whats-your.name> wrote: > on a httpd for serving non-RDF formats (emails, feeds, texts) as HTML, which has worked fine for a decade but for obvious reasons relating to increasing tool-surface-area, in the process of eliminating the httpd portion of this (ultimately there'll be a gem called rdf-readers-notrdf or whatever, and everything else goes away) > > i've seen supporting extensions in the file/path sense as a way to express desired content-type, as opposd to saying curl -H "Accept: text/ntriples" or an adhoc querystring like ?format=ntriples. apparently, this is not specified in a spec, but i've seen AndyS recommend it on IRC and/or mailinglists, and seen it implemented in various servers from both CSail/MIT and various Bristolians > > #conneg on my server https://github.com/hallwaykid/rrww/blob/master/ruby/HTTP.rb#L61 gives extensions priority over Accept: content-types from HTTP headers. > > { '.html' => 'text/html', > '.n3' => 'text/n3', > }[File.extname self['uri']].do{|mime| > return mime} > > looking at rack-linkeddata, it does offer an override, but it looks like the middleware sets this once, and it applies to every request? > > use Rack::LinkedData::ContentNegotation, :format => :ttl > > this goes in config.ru, or > > Rack::Builder.new { > use Rack::Deflater > use Rack::LinkedData > run App > }.to_app > > so my question is, how to set :format per-request (everything i know about Ruby is from hackin on Perl as an uneducated "hack", or fiddling with Smalltalk in "Squeak" in preschool, further warped by only reading books about ML-family languages, so it's possible i'm overlooking an "idiomatic ruby" way to do this, or maybe thios library just needs a patch (or some bearded type to say NO - the extension-hack is unspecified, don't bother..) I believe a previous version of the RDF Distiller [1][2] used a Sinatra content-negotiation package to do this, but it became incompatible, so I just moved it into the application logic. Doing extension-based content negotiation in Rack::LinkedData::ContentNegotiation would be reasonable, although not useful for the distiller, which almost always generates HTML with the distilled data contained in a form field. To do this, you'd just do a RDF::Reader.for(:file_extension => ext) and use that to set the reader instead of the Accept header. I'd certainly consider a pull request to add this, but we need to have good RSpec tests to validate. Gregg [1] https://github.com/gkellogg/rdf-distiller [2] http://rdf.greggkellogg.net/
Received on Friday, 14 March 2014 01:53:26 UTC