Sha256: 9b7e31dac687abe592335f137b5528a008a1d5b4913d89983e45e94119524019

Contents?: true

Size: 492 Bytes

Versions: 11

Compression:

Stored size: 492 Bytes

Contents

module CubaApi
  class Ext2MimeRack
    def initialize( app, *allowed)
      @app = app
      @allowed = allowed
    end
  
    def call(env)
      ext = env[ 'PATH_INFO' ].sub( /.*\./, '' )
      if ext && @allowed.member?( ext )
        mime = Rack::Mime.mime_type( '.' + ext )
        env[ 'PATH_INFO_ORIG' ] = env[ 'PATH_INFO' ].dup
        env[ 'HTTP_ACCEPT' ] = mime
        env[ 'PATH_INFO' ].sub!( /\..*/, '' )
      end
      status, headers, body = @app.call(env)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cuba-api-0.6.3 lib/cuba_api/rack/ext2mime_rack.rb~
cuba-api-0.6.2 lib/cuba_api/rack/ext2mime_rack.rb~
cuba-api-0.6.1 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.6.0 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.5.1 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.5.0 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.4.0 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.3.3 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.3.2 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.3.1 lib/cuba_api/ext2mime_rack.rb
cuba-api-0.3.0 lib/cuba_api/ext2mime_rack.rb