class Susanoo::Application::Static
This controller is responsible for serving/building static files. It does not supports regex at this time.
Public Instance Methods
build(generator, options)
click to toggle source
# File lib/susanoo/controllers/static.rb, line 23 def build(generator, options) route = options[:route] file = route.path_for_generation[1..-1] generator.copy_file file, "www/#{route.path_for_generation}" end
call(env)
click to toggle source
TODO: Add regext support to this controller
# File lib/susanoo/controllers/static.rb, line 9 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