Sha256: 1187aa4647bb2e0fc5d6aee28ebefe0c301206cec8bc24af2491f9c5b521e904
Contents?: true
Size: 1.86 KB
Versions: 2
Compression:
Stored size: 1.86 KB
Contents
require 'orange-core/middleware/base' require 'pathname' module Orange::Middleware # This is an adapted Orange version of mynyml's rack-abstract-format # available at http://github.com/mynyml/rack-abstract-format class AbstractFormat < Base def init(opts = {}) end def packet_call(packet) path_info = packet['route.path'] || packet.env['PATH_INFO'] path = Pathname(path_info) packet['route.path'] = path.to_s.sub(/#{path.extname}$/,'') if Rack::Mime::MIME_TYPES.include?(path.extname) packet.env['HTTP_ACCEPT'] = concat(packet.env['HTTP_ACCEPT'], Rack::Mime.mime_type(path.extname)) pass packet end private def concat(accept, type) (accept || '').split(',').unshift(type).compact.join(',') end end end # # Copyright © 2009 Martin Aumont (mynyml) # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies # of the Software, and to permit persons to whom the Software is furnished to do # so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
orange-core-0.7.1 | lib/orange-core/middleware/abstract_format.rb |
orange-core-0.7.0 | lib/orange-core/middleware/abstract_format.rb |