extension for MIME type in rack-linkeddata

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..)

Received on Tuesday, 11 March 2014 03:27:47 UTC