Skip to content

Instantly share code, notes, and snippets.

@zhongwencool
Created January 4, 2017 02:50
Show Gist options
  • Save zhongwencool/ae2ec1bf842f08078e05a5f667c5cabb to your computer and use it in GitHub Desktop.
Save zhongwencool/ae2ec1bf842f08078e05a5f667c5cabb to your computer and use it in GitHub Desktop.
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