Sha256: a9739e1fffc78062664d33734a3327a147579904fa628ddb7fc51bf117a12a17

Contents?: true

Size: 435 Bytes

Versions: 11

Compression:

Stored size: 435 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[ '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/ext2mime_rack.rb~
cuba-api-0.6.2 lib/cuba_api/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~