寻找任何赞赏的帮助。
我正在使用 Heroku 上托管的 Rails 3.0.10 应用程序,该应用程序最近添加了ssl。我的 Api :: BaseController
alias_method :original_inherited, :inherited
def inherited(subclass)
original_inherited(subclass)
load File.join("#{Rails.root}", "app", "controllers",
"api", "#{extract_filename(subclass)}")
subclass.action_methods.each do |method|
regex = Regexp.new("^(.*)_(\\d+)$")
if match = regex.match(method)
key = "#{subclass.to_s}##{match[1]}"
@@versions[match[2].to_i] = true
@@registered_methods[key] ||= {}
@@registered_methods[key][match[2].to_i] = true
subclass.instance_eval do
define_method(match[1].to_sym) {}
end
end
end
subclass.reset_action_methods
end
def extract_filename(subclass)
classname = subclass.to_s.split('::')[1]
parts = classname.underscore.split('_')
"#{parts.reject{|c| c == 'controller'}.join('_')}_controller.rb"
end
def reset_action_methods
@action_methods = nil
action_methods
end
当我发出任何请求时,它就会在这里出现,并且在某些API中,它会像这样进行重定向调用。
Status : 302 Found
Location : http://3a235934.ngrok.io/en/api/v2/vouchers/show_voucher?auth_token=SxSkyf4GykApgzhSyvWI&id=693
然后给出答复
Status Code: 200 OK
Cache-Control: max-age=0, private, must-revalidate
Content-Length: 82
Content-Type: application/json; charset=utf-8
Date: Thu, 25 Oct 2018 06:32:44 GMT
Etag: "92234fded00f59326ca858b732179de3"
Server: WEBrick/1.3.1 (Ruby/2.2.10/2018-03-28)
X-Runtime: 5.448165
X-Ua-Compatible: IE=Edge,chrome=1