Sha256: 81751860688b4afacb50e7ae80baab696879cf17bb6607b18b45b10be159d76c
Contents?: true
Size: 757 Bytes
Versions: 8
Compression:
Stored size: 757 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, options) route = options[:route] file = route.path_for_generation[1..-1] generator.copy_file file, "www/#{route.path_for_generation}" end end end
Version data entries
8 entries across 8 versions & 1 rubygems