Class: Rack::LDP::ContentNegotiation
- Inherits:
-
Rack::LinkedData::ContentNegotiation
- Object
- Rack::LinkedData::ContentNegotiation
- Rack::LDP::ContentNegotiation
- Defined in:
- lib/rack/ldp.rb
Overview
Specializes Rack::LinkedData::ContentNegotiation, making the default return type ‘text/turtle’.
Constant Summary collapse
- DEFAULT_PREFIXES =
Hash[*RDF::Vocabulary.map { |v| [v.__prefix__, v.to_uri] }.flatten] .freeze
Instance Method Summary collapse
-
#find_writer_for_content_type(content_type) ⇒ Object
The default LinkedData Conneg doesn’t support wildcard operators.
-
#initialize(app, options = {}) ⇒ ContentNegotiation
constructor
A new instance of ContentNegotiation.
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, = {}) [:default] ||= 'text/turtle' [: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.
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 |