Last active
December 17, 2015 21:39
-
-
Save godfat/5676447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-core' | |
module RestCore | |
middleware = Class.new | |
middleware.module_eval do | |
def initialize app | |
@app = app | |
end | |
def call env, &k | |
puts "Calling" | |
@app.call(env, &k) | |
end | |
end | |
Circular = Builder.client do | |
use middleware | |
end | |
Circular::Middleware = middleware | |
end | |
puts RC::Circular | |
puts RC::Circular::Middleware | |
puts RC::Circular.new.head('http://example.com/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-core' | |
module RestCore | |
middleware = Class.new | |
middleware.module_eval do | |
def initialize app | |
@app = app | |
end | |
def call env, &k | |
puts env['secret'] | |
@app.call(env, &k) | |
end | |
end | |
Secret = Builder.client(:secret) do | |
use middleware | |
end | |
Secret::Middleware = middleware | |
end | |
puts RC::Secret.new(:secret => 'mission').head('http://example.com/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-core/middleware' | |
require 'rest-core/util/hmac' | |
class RestCore::Signature | |
def self.members; [:secret]; end | |
include RestCore::Middleware | |
def call env, &k | |
uri = request_uri(env) | |
sig = Hmac.sha1(secret(env), uri) | |
app.call(env.merge(REQUEST_QUERY => {}, | |
REQUEST_PATH => "#{uri}&Signature=#{sig}", &k)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
請問一下,你說的 dry run是原本就會丟出 timeout 囉?