Class: Grape::Middleware::Prefixer

Inherits:
Base
  • Object
show all
Defined in:
lib/grape/middleware/prefixer.rb

Instance Attribute Summary

Attributes inherited from Base

#app, #env, #options

Instance Method Summary collapse

Methods inherited from Base

#after, #call, #call!, #default_options, #initialize, #request, #response

Constructor Details

This class inherits a constructor from Grape::Middleware::Base

Instance Method Details

#beforeObject



13
14
15
16
17
18
# File 'lib/grape/middleware/prefixer.rb', line 13

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

#prefixObject



7
8
9
10
11
# File 'lib/grape/middleware/prefixer.rb', line 7

def prefix
  prefix = options[:prefix] || ""
  prefix = Rack::Mount::Utils.normalize_path(prefix)
  prefix
end