Sha256: 0e79dc4c91acf5a69c3b60459969e3d7a3a26a28dbf64d50d66c356104178021
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
require 'helmet/templates' require 'helmet/response' module Helmet # Handle each request and provide usefull methods for request handling class Handler include Templates # Request environment attr_reader :env attr_reader :response def initialize(env) @env = env @response = Response.new(env) end # @return (Response) request response def handle!(&block) @response.body = instance_exec(&block) @response.format_response end # @return (Rack::Session) the current session data def session @env['rack.session'] end # Creates a redirect HTTP response def redirect(uri) @response.status = 302 @response.header['Location'] = uri @response.body = '' halt end # halt the execution def halt(body=nil) @response.body = body if body throw :halt end # @return (Integer) response status code def status @response.status end # set response status code def status(code) @response.status = code end # @return (Hash) response header def header @response.header end # @return (String) response body def body @response.body end def content_type(type) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
helmet-0.1.1 | lib/helmet/handler.rb |
helmet-0.1.0 | lib/helmet/handler.rb |