Sha256: 5b769b573378bf6773afe7ad98096316e9637c8b7bb6f3019f29786a5b275440

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

module Rack
    module Blogengine
        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, target)
            status = 200
    	    header = {"Content-Type" => "text/html; charset=UTF-8"}
    	    path = env["PATH_INFO"]

    	    documents = DocParser.parseInDocuments(target)
           
            # Iterate through available docs, if nothing matched return nil
    	    documents.each do |doc|
    	       if doc[:path] == path
    		      route_response = {
    		          "route" => 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.0.3 lib/rack/blogengine/application_router.rb