Sha256: 001fb62a82cd3da17f5f1477d72331a5bacf38ed8697f9545a94e2ff56b49707

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

module Rack
  module Blogengine
    # 
    # ApplicationRouter routes the request to the proper, parsed .content (layout.html + .content) file
    # 
    # @author [benny]
    # 
    class ApplicationRouter
      # Maps documents to routes.
      # @param env Env Contains path info etc...
      # @param target Target folder
      # @return [Hash] route Hash {:path => "/foo", :response => [Array]}
      def self.map_route(env, documents)
        status = 200
        header = {"Content-Type" => "text/html; charset=UTF-8"}
        path = env["PATH_INFO"]
           
        # Iterate through available docs, if nothing matched return nil
        documents.each do |doc|
          if doc[:path] == path
            route_response = {
              "path" => path,
              "response" => [status, header, [doc[:html]] ]
            }

            return route_response
          end
        end

        return nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-blogengine-0.2.0 lib/rack/blogengine/application_router.rb