Class: Grape::Middleware::Prefixer

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

Constant Summary

Constants inherited from Base

Base::CONTENT_TYPES

Instance Attribute Summary

Attributes inherited from Base

#app, #env, #options

Instance Method Summary collapse

Methods inherited from Base

#after, #call, #call!, #content_type, #content_types, #default_options, #initialize, #mime_types, #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