Sha256: 2e701ba4c1a0bda1044202696e729cdbe2657a6c1eeca983d94cb269be8b192a
Contents?: true
Size: 1.23 KB
Versions: 11
Compression:
Stored size: 1.23 KB
Contents
module RubySlippers module Engine class App attr_reader :config, :site def initialize config = {}, &blk @config = config.is_a?(Config) ? config : Config.new(config) @config.instance_eval(&blk) if block_given? @site = RubySlippers::Engine::Site.new(@config) end def call env @request = Rack::Request.new env @response = Rack::Response.new return [400, {}, []] unless @request.get? path, mime = @request.path_info.split('.') route = (path || '/').split('/').reject {|i| i.empty? } response = @site.go(route, env, *(mime ? mime : [])) @response.body = [response[:body]] @response['Content-Length'] = response[:body].length.to_s unless response[:body].empty? @response['Content-Type'] = Rack::Mime.mime_type(".#{response[:type]}") # Set http cache headers @response['Cache-Control'] = if RubySlippers::Engine.env == 'production' "public, max-age=#{@config[:cache]}" else "no-cache, must-revalidate" end @response['ETag'] = %("#{Digest::SHA1.hexdigest(response[:body])}") @response.status = response[:status] @response.finish end end end end
Version data entries
11 entries across 11 versions & 1 rubygems