Class: RouteDowncaser::DowncaseRouteMiddleware
- Inherits:
-
Object
- Object
- RouteDowncaser::DowncaseRouteMiddleware
- Defined in:
- lib/route_downcaser/downcase_route_middleware.rb
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app) ⇒ DowncaseRouteMiddleware
constructor
A new instance of DowncaseRouteMiddleware.
Constructor Details
#initialize(app) ⇒ DowncaseRouteMiddleware
Returns a new instance of DowncaseRouteMiddleware.
7 8 9 |
# File 'lib/route_downcaser/downcase_route_middleware.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#_call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/route_downcaser/downcase_route_middleware.rb', line 15 def _call(env) path_info = env["PATH_INFO"] # Don't touch anything, if path is part of exclude_patterns return @app.call(env) if excluded?([path_info]) # Downcase path_info if applicable path_info = downcased_uri(path_info) # If redirect configured, then return redirect request, if either # path_info has changed if RouteDowncaser.redirect && env["REQUEST_METHOD"] == "GET" return redirect_header(path_info) if path_info.present? && path_info != env["PATH_INFO"] end env["PATH_INFO"] = path_info.to_s if path_info # Default just move to next chain in Rack callstack # calling with downcased uri if needed @app.call(env) end |
#call(env) ⇒ Object
11 12 13 |
# File 'lib/route_downcaser/downcase_route_middleware.rb', line 11 def call(env) dup._call(env) end |