Sha256: 7d6a90f44c9e973aaeb8b00b8f2f661dba58ae24f7c4979c8e712602a1d76635
Contents?: true
Size: 725 Bytes
Versions: 2
Compression:
Stored size: 725 Bytes
Contents
require 'rack' class Susanoo::Application # This controller is responsible for serving/building static files. # It does not supports regex at this time. class Static < Susanoo::Controller # TODO: Add regext support to this controller def call(env) path = env['REQUEST_PATH'] file = ::File.join(project_root, 'src', path) if ::File.exist? file [200, {'Content-Type' => 'text/plain'}, [::File.new(file).read]] else [404, {}, ['Can not find the file']] end end def build(generator, route) file = route.path_for_generation[1..-1] generator.copy_file file, "www/#{route.path_for_generation}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
susanoo-0.11.1 | lib/susanoo/controllers/static.rb |
susanoo-0.10.0 | lib/susanoo/controllers/static.rb |