module Qeweney
def self.rack(&block)
def self.rack(&block) proc do |env| adapter = RackRequestAdapter.new(env) req = Request.new(adapter.request_headers, adapter) block.(req) adapter.rack_response end end
def self.rack_env_from_request(request)
def self.rack_env_from_request(request) Hash.new do |h, k| h[k] = rack_env_value_from_request(request, k) end end
def self.rack_env_value_from_request(request, key)
def self.rack_env_value_from_request(request, key) case key when 'REQUEST_METHOD' then request.method.upcase when 'PATH_INFO' then request.path when 'QUERY_STRING' then request.query_string || '' when 'SERVER_NAME' then request.headers['host'] when 'rack.input' then InputStream.new(request) when HTTP_HEADER_RE then request.headers[$1.gsub('_', '-').downcase] else RACK_ENV[key] end end
def self.route(&block)
def self.route(&block) ->(r) { r.route(&block) } end