Public Instance methods
on_type(type, &block)
Yields if the given type matches the requested data type and halts the request afterwards, returning the result of the block.
[show source]
# File lib/roda/plugins/type_routing.rb 159 def on_type(type, &block) 160 return unless type == requested_type 161 response[RodaResponseHeaders::CONTENT_TYPE] ||= roda_class.type_routing_opts[:types][type] 162 always(&block) 163 end
real_remaining_path()
Append the type routing extension back to the path if it was removed before routing.
[show source]
# File lib/roda/plugins/type_routing.rb 176 def real_remaining_path 177 if @type_routing_extension 178 "#{super}.#{@type_routing_extension}" 179 else 180 super 181 end 182 end
requested_type()
Returns the data type the client requests.
[show source]
# File lib/roda/plugins/type_routing.rb 166 def requested_type 167 return @requested_type if @requested_type 168 169 opts = roda_class.type_routing_opts 170 @requested_type = accept_response_type if opts[:use_header] 171 @requested_type ||= opts[:default_type] 172 end