Sha256: ed0d6704b945f16e726709f2b53a0a94433155df56e0029376949ec9c074eaa3

Contents?: true

Size: 949 Bytes

Versions: 42

Compression:

Stored size: 949 Bytes

Contents

require 'orange-core/middleware/base'

module Orange::Middleware
  # The FlexRouter middleware takes a resource that can route paths and
  # then intercepts routes for that resource. By default,
  # it uses the Orange::SitemapResource. 
  # 
  # The resource is automatically loaded into the core as 
  # :sitemap. The resource must respond to "route?(path)" 
  # and "route(packet)".  
  # 
  # Pass a different routing resource using the :resource arg
  class FlexRouter < Base    
    # Sets the sitemap resource as the router if the resource can accept 
    # the path.
    def packet_call(packet)
      return (pass packet) if packet['route.router']  # Don't route if other middleware
                                                      # already has
      path = packet['route.path'] || packet.request.path_info
      packet['route.router'] = orange[:sitemap] if orange[:sitemap].route?(packet, path)
      pass packet
    end
    
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
orange-0.3.5 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.3.4 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.3.3 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.3.2 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.3.1 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.3.0 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.11 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.9 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.8 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.7 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.6 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.5 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.4 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.2.3 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.1.10 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.1.8 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.1.7 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.1.4 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.1.2 lib/orange-more/sitemap/middleware/flex_router.rb
orange-0.1.0 lib/orange-more/sitemap/middleware/flex_router.rb