class StormyServer
Public Class Methods
new(config_options)
click to toggle source
# File lib/stormy_server.rb, line 5 def initialize(config_options) @app = StormyApp.new(config_options) @file_server = Stormy::Static.new(File.join(@app.root,"public")) end
Public Instance Methods
call(env)
click to toggle source
# File lib/stormy_server.rb, line 10 def call(env) render(::Rack::Utils.unescape(env['PATH_INFO'])) end
render(path)
click to toggle source
# File lib/stormy_server.rb, line 15 def render(path) if @file_server.can_serve?(path) @file_server.serve(path) else output = render_page(path) if output output else [404, {"Content-Type" => "text/html"}, [ "Page Not Found" ] ] end end end
render_page(path)
click to toggle source
# File lib/stormy_server.rb, line 28 def render_page(path) @page = @app.page(path,{ "path" => path }) if @page.valid? @page.render else @error_page = @app.page(@app.page_not_found, { "path" => @app.page_not_found }) if @error_page.valid? @error_page.render(404) end end end