Sha256: 2a29eeb067f69aa3c9e242178aa3e9a059f087a14c1a39a8db6b1ec8b50a7513
Contents?: true
Size: 812 Bytes
Versions: 2
Compression:
Stored size: 812 Bytes
Contents
require 'rack' require 'haml' module Compaa class RackApp attr_writer :root_directory DEFAULT_ROOT = Dir.pwd def app template = File.read File.expand_path 'template.haml', File.dirname(__FILE__) root = @root_directory or DEFAULT_ROOT Rack::Builder.new do use Rack::Static, :urls => ['/artifacts'], :root => root run lambda { |env| request = Rack::Request.new env if request.path == '/' and request.params.has_key? 'filepath' locals = { :filepath => request.params['filepath'] } body = Haml::Engine.new(template).render Object.new, locals [ 200, { 'Content-Type' => 'text/html' }, [body] ] else [ 404, {}, ['Not found'] ] end } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
compaa-0.0.3 | lib/compaa/rack_app.rb |
compaa-0.0.2 | lib/compaa/rack_app.rb |