Sha256: e469a606eaf30008cb8393c1f1eb6e20da89d965d682a0d270c899b9ea9513b5
Contents?: true
Size: 692 Bytes
Versions: 2
Compression:
Stored size: 692 Bytes
Contents
class Guinness::Server def initialize(app) @app = app end def call(env) body = render File.join(@app.settings[:root], env['PATH_INFO']) if body [200, { 'Content-Type' => Rack::Mime.mime_type(File.extname(env['PATH_INFO']), 'text/html') }, [body]] else [404, { 'Content-Type' => 'text/plain' }, 'Not Found'] end end def render(path) return File.read path if File.file? path # default to index if path to directory path = File.join(path, 'index') if Dir.exists? path # return the first filename that matches file template = Dir[File.join("#{path}*")].first return Guinness::View.new(template).render if template end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
guinness-0.1.0 | lib/guinness/server.rb |
guinness-0.0.2 | lib/guinness/server.rb |