initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rack'
|
||||
require 'json'
|
||||
|
||||
require_relative 'response'
|
||||
|
||||
module FO::HTTP
|
||||
class Request < Rack::Request
|
||||
def content
|
||||
if get? || options?
|
||||
return nil
|
||||
end
|
||||
|
||||
begin
|
||||
body = body.read
|
||||
if media_type.match?(/^application\/json/i)
|
||||
return json
|
||||
elsif media_type.match?(/^application\/form-data/i) ||
|
||||
media_type.match?(/^application\/x-www-form-urlencoded/i)
|
||||
return params
|
||||
end
|
||||
body
|
||||
ensure
|
||||
body.rewind
|
||||
end
|
||||
end
|
||||
|
||||
def path_params
|
||||
self.env['router.params']
|
||||
end
|
||||
|
||||
def new_response(status)
|
||||
FO::HTTP::Response.new(self).status(status)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user