Class: Rack::LDP::ContentNegotiation

Inherits:
Rack::LinkedData::ContentNegotiation
  • Object
show all
Defined in:
lib/rack/ldp.rb

Overview

Specializes Rack::LinkedData::ContentNegotiation, making the default return type ‘text/turtle’.

See Also:

  • making

Constant Summary collapse

DEFAULT_PREFIXES =
Hash[*RDF::Vocabulary.map { |v| [v.__prefix__, v.to_uri] }.flatten]
.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ ContentNegotiation

Returns a new instance of ContentNegotiation.



120
121
122
123
124
# File 'lib/rack/ldp.rb', line 120

def initialize(app, options = {})
  options[:default] ||= 'text/turtle'
  options[:prefixes] ||= DEFAULT_PREFIXES.dup
  super
end

Instance Method Details

#find_writer_for_content_type(content_type) ⇒ Object

The default LinkedData Conneg doesn’t support wildcard operators. We patch in support for ‘text/*’ manually, giving Turtle. This should be considered helpful by LDP clients.

See Also:

  • Rack::LinkedData::ContentNegotiation#find_writer_for_content_type


132
133
134
135
136
# File 'lib/rack/ldp.rb', line 132

def find_writer_for_content_type(content_type)
  return [RDF::Writer.for(:ttl), 'text/turtle'] if
    content_type == 'text/*'
  super
end