class Locomotive::Steam::Middlewares::PageNotFound

When rendering the page, the developer can stop it at anytime by raising an PageNotFoundException exception. Instead of the page, the 404 not found page will be rendered.

This is particularly helpful with the dynamic routing feature to avoid duplicated page content (different urls, same HTTP 200 code but same blank page).

Public Instance Methods

_call() click to toggle source
# File lib/locomotive/steam/middlewares/page_not_found.rb, line 16
def _call
  begin
    self.next
  rescue Locomotive::Steam::PageNotFoundException => e
    # fetch the 404 error page...
    env['steam.page'] = page_finder.find('404')

    # ... and render it instead
    render_page
  end
end

Private Instance Methods

page_finder() click to toggle source
# File lib/locomotive/steam/middlewares/page_not_found.rb, line 30
def page_finder
  services.page_finder
end