Sha256: 425d914f506d3d1a517f65236006fdbdaecbed87d5003ac085b1ce39ccc6262a

Contents?: true

Size: 479 Bytes

Versions: 15

Compression:

Stored size: 479 Bytes

Contents

require 'rack/mount/utils'
require 'grape'

module Grape
  module Middleware
    class Prefixer < Base
      def prefix
        prefix = options[:prefix] || ""
        prefix = Rack::Mount::Utils.normalize_path(prefix)
        prefix
      end
      
      def before
        if env['PATH_INFO'].index(prefix) == 0
          env['PATH_INFO'].sub!(prefix, '')
          env['PATH_INFO'] = Rack::Mount::Utils.normalize_path(env['PATH_INFO'])
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
grape-0.2.1.1 lib/grape/middleware/prefixer.rb
grape-0.2.3 lib/grape/middleware/prefixer.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/grape-0.2.2/lib/grape/middleware/prefixer.rb
fragrant-0.0.4 vendor/grape/lib/grape/middleware/prefixer.rb
grape-0.2.2 lib/grape/middleware/prefixer.rb
fragrant-0.0.3 vendor/grape/lib/grape/middleware/prefixer.rb
fragrant-0.0.2 vendor/grape/lib/grape/middleware/prefixer.rb
fragrant-0.0.1 vendor/grape/lib/grape/middleware/prefixer.rb
grape-0.2.1 lib/grape/middleware/prefixer.rb
grape-0.2.0 lib/grape/middleware/prefixer.rb
grape-0.1.5 lib/grape/middleware/prefixer.rb
grape-0.1.4 lib/grape/middleware/prefixer.rb
grape-0.1.3 lib/grape/middleware/prefixer.rb
grape-0.1.1 lib/grape/middleware/prefixer.rb
grape-0.1.0 lib/grape/middleware/prefixer.rb