aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-05-08 02:07:39 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-05-08 15:24:17 +0900
commit904fe92bb9f25b6e4582aaef0d00f1841e4bee24 (patch)
treef4272016b2a9a9b5250f03dba402d5669b7c1ac0
parentdb7f141a7ea0d486599e02c839f12ddc72cdd152 (diff)
downloadplum-topic/client-redesign-api.tar.gz
readme/example: replace obsolete Client#[http-method]! examplestopic/client-redesign-api
They are gone. Instead, replace these examples with new Reponse#join methods.
-rw-r--r--README.md6
-rw-r--r--examples/client/twitter.rb10
2 files changed, 9 insertions, 7 deletions
diff --git a/README.md b/README.md
index b8bba11..b440d6f 100644
--- a/README.md
+++ b/README.md
@@ -71,10 +71,10 @@ If the server does't support HTTP/2, `Plum::Client` tries to use HTTP/1.x instea
##### Sequential request
```ruby
-client = Plum::Client.start("http2.rhe.jp", 443, user_agent: "nyaan")
-res1 = client.get!("/", headers: { "accept" => "*/*" })
+client = Plum::Client.start("http2.rhe.jp", user_agent: "nyaan")
+res1 = client.get("/", headers: { "accept" => "*/*" }).join
puts res1.body # => "..."
-res2 = client.post!("/post", "data")
+res2 = client.post("/post", "data").join
puts res2.body # => "..."
client.close
diff --git a/examples/client/twitter.rb b/examples/client/twitter.rb
index 88f742f..00d41c8 100644
--- a/examples/client/twitter.rb
+++ b/examples/client/twitter.rb
@@ -40,10 +40,12 @@ Plum::Client.start("userstream.twitter.com", 443) { |streaming|
if /にゃーん/ =~ json["text"]
args = { "status" => "@#{json["user"]["screen_name"]} にゃーん",
"in_reply_to_status_id" => json["id"].to_s }
- rest.post!("/1.1/statuses/update.json",
- args.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&"),
- headers: { "authorization" => SimpleOAuth::Header.new(:post, "https://api.twitter.com/1.1/statuses/update.json", args, credentials).to_s,
- "content-type" => "application/x-www-form-urlencoded" })
+ rest.post(
+ "/1.1/statuses/update.json",
+ args.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&"),
+ headers: { "authorization" => SimpleOAuth::Header.new(:post, "https://api.twitter.com/1.1/statuses/update.json", args, credentials).to_s,
+ "content-type" => "application/x-www-form-urlencoded" }
+ ).join
end
end
}