Sha256: fd46f54a581672d9a3605e2e2546381b3a98f191ab06cf928268fab04bb1d675
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
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, target) status = 200 header = {"Content-Type" => "text/html; charset=UTF-8"} path = env["PATH_INFO"] # TODO: dont parse all docs on every request -> doc cache (maybe parse at rack-blogengine run) # for fasten up accessing eg contentoperator in layout.html which has faraday request -> too big load times on every request!!! 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.1.9 | lib/rack/blogengine/application_router.rb |