Sha256: b9026fe891fa825d97ab7e743c778e66187ce1d87c476ee77b4c634b6a21a53e
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
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 # TODO: Dont iterate through every doc, get requested doc from DocParser # Operators should have access to ALL available docs (title, path, html etc) 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
3 entries across 3 versions & 1 rubygems