class Dibbler::Middlewares::Slug
Public Class Methods
new(app)
click to toggle source
# File lib/dibbler/middlewares/slug.rb, line 16 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/dibbler/middlewares/slug.rb, line 20 def call(env) if filter(env) @app.call(env) else # Match locale from path locale, translation = Dibbler.disassemble(env["PATH_INFO"]) # Translate to original and modify request original = Dibbler.slug_model.translation_to_original(I18n.locale, translation) # Previously matched locale used unless original.nil? original = Dibbler.assemble(locale, original) env["REQUEST_PATH"] = original env["PATH_INFO"] = original env["REQUEST_URI"] = original + "?" + env["QUERY_STRING"] end @app.call(env) end end
Protected Instance Methods
filter(env)
click to toggle source
# File lib/dibbler/middlewares/slug.rb, line 42 def filter(env) return true if env["PATH_INFO"].start_with?("/assets/") false end