我记得在GitHub上看过这个描述的宝石,但现在我找不到了。
这个想法是,它可以让你看到其他宝石用来实现其魔力的实际API调用/服务端点。
我不记得它是专门用于HTTP还是什么。
答案 0 :(得分:3)
我不知道那个gem,但是你可以通过打开ruby的Net :: HTTP类来轻松地重新创建这个功能,对现有方法进行别名并在实际的HTTP调用之前添加一些日志记录调用。
例如,以下是如何将对GET的调用打印到stdout:
require 'rubygems' require 'net/http' class Net::HTTP # Note that you have to be in the singleton class to alias a class method class << self alias_method :orig_get, :get def get(uri_or_host, path=nil, port=nil) # here's where you log theactivity, before calling the original method puts "GET: #{uri_or_host}#{':' + port if port}#{path}" orig_get(uri_or_host, path, port) end end end