Created
January 4, 2017 02:50
-
-
Save zhongwencool/ae2ec1bf842f08078e05a5f667c5cabb 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
defmodule Client do | |
use Maxwell.Builder, ~w(post)a | |
middleware Maxwell.Middleware.BaseUrl, "http://httpbin.org" | |
middleware Maxwell.Middleware.Opts, [connect_timeout: 10000, recv_timeout: 20000] | |
middleware Maxwell.Middleware.Json | |
adapter Maxwell.Adapter.Hackney | |
@doc """ | |
Post by stream | |
###Example | |
["1", "2", "3"] |> Stream.map(fn(x) -> List.duplicate(x, 2) end) |> Client.post_stream | |
""" | |
def post_stream(stream) do | |
new | |
|> put_path("/post") | |
|> put_req_body(stream) | |
|> post! | |
|> get_resp_body("data") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment