Sha256: ba2dfa0cb236a6de2906cccfde7764cfbd60ae8c8d88c78c4feac3714fee4744
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'rack/request' module Jeanine class Request < Rack::Request FORMAT_REGEX = %r{\.(\w+)\z} def initialize(env) env['PATH_INFO'] = '/' if env['PATH_INFO'].empty? if env['PATH_INFO'].include?(".") format = env['PATH_INFO'].match(FORMAT_REGEX) if format @format = format.captures[0] env['PATH_INFO'].gsub!(FORMAT_REGEX, '') end end super end def post? request_method == 'POST' end def get? request_method == 'GET' end def delete? request_method == 'DELETE' end def put? request_method == 'PUT' end def patch? request_method == 'PATCH' end def options? request_method == 'options' end def head? request_method == 'head' end def json? format == 'json' end def mime_type @mime_type ||= Mimes::MIME_TYPES_INVERTED[content_type] end def format @format || Rack::Mime::MIME_TYPES[content_type] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jeanine-0.5.0 | lib/jeanine/request.rb |