Cables v0.2.1 Cables View Source
Asynchronous multiplexed HTTP/2 connection manager.
Create a new Cable using Cable.new/2. Cables will immediately open min_connections specified in the profile.
Examples
{:ok, cable} = Cables.new("https://nghttp2.org/")
{:ok, %Cables.Response{status: 200}} = Cables.get(cable, "/httpbin/get")
Link to this section Summary
Functions
Create a named supervised pool to include in
Simple DELETE request with Cables.Response
Simple GET request with Cables.Response
Simple HEAD request with Cables.Response
Create a new pool and attach it to the global Cables supervisor
Simple OPTIONS request with Cables.Response
Simple PATCH request with Cables.Response
Simple POST request with Cables.Response
Simple PUT request with Cables.Response
Start a request and handle it with the request_handler. Cables.Handler
This gives you full control over sending and recieving stream data
Send a piece of data. Make sure to use &send_final_data/3 to send the final chunk
Send a piece of data and indicate that the request body has finished
Link to this section Types
http_method() :: :get | :post | :head | :put | :patch | :options | :delete | String.t()
Link to this section Functions
Create a named supervised pool to include in
Examples
iex> children = [ Cables.child_spec(:my_named_pool, "https://nghttp2.org/") ]
...> {:ok, _pid} = Supervisor.start_link(children, strategy: :one_for_one)
...> {:ok, %Cables.Response{status: status}} = Cables.post(:my_named_pool, "/httpbin/post", [], "hello world")
...> status
200
delete( Cabel.t(), String.t(), [{String.t(), String.t()}], iodata(), request_opts() ) :: {:ok, Cables.Response.t()} | {:error, any()}
Simple DELETE request with Cables.Response
Examples
iex> {:ok, cable} = Cables.new("https://nghttp2.org/")
...> {:ok, %Cables.Response{status: status}} = Cables.delete(cable, "/httpbin/delete")
...> status
200
get(Cabel.t(), [{String.t(), String.t()}], String.t(), request_opts()) ::
{:ok, Cables.Response.t()} | {:error, any()}
Simple GET request with Cables.Response
Examples
iex> {:ok, cable} = Cables.new("https://nghttp2.org/")
...> {:ok, %Cables.Response{status: status}} = Cables.get(cable, "/httpbin/get")
...> status
200
iex> {:ok, cable} = Cables.new("https://nghttp2.org/")
...> {:ok, %Cables.Response{status: status}} = Cables.get(cable, "/httpbin/delay/8", [{"my-custom-header", "some_header_value"}], connection_timeout: 10_000, pool_timeout: 10_000)
...> status
200
head(Cabel.t(), [{String.t(), String.t()}], String.t(), request_opts()) ::
{:ok, Cables.Response.t()} | {:error, any()}
Simple HEAD request with Cables.Response
Create a new pool and attach it to the global Cables supervisor.
options(Cabel.t(), [{String.t(), String.t()}], String.t(), request_opts()) ::
{:ok, Cables.Response.t()} | {:error, any()}
Simple OPTIONS request with Cables.Response
patch( Cabel.t(), String.t(), [{String.t(), String.t()}], iodata(), request_opts() ) :: {:ok, Cables.Response.t()} | {:error, any()}
Simple PATCH request with Cables.Response
Examples
iex> {:ok, cable} = Cables.new("https://nghttp2.org/")
...> {:ok, %Cables.Response{status: status}} = Cables.patch(cable, "/httpbin/patch", [], "hello world")
...> status
200
post( Cabel.t(), String.t(), [{String.t(), String.t()}], iodata(), request_opts() ) :: {:ok, Cables.Response.t()} | {:error, any()}
Simple POST request with Cables.Response
Examples
iex> {:ok, cable} = Cables.new("https://nghttp2.org/")
...> {:ok, %Cables.Response{status: status}} = Cables.post(cable, "/httpbin/post", [], "hello world")
...> status
200
put(Cabel.t(), String.t(), [{String.t(), String.t()}], iodata(), request_opts()) :: {:ok, Cables.Response.t()} | {:error, any()}
Simple PUT request with Cables.Response
Examples
iex> {:ok, cable} = Cables.new("https://nghttp2.org/")
...> {:ok, %Cables.Response{status: status}} = Cables.put(cable, "/httpbin/put", [], "hello world")
...> status
200
Start a request and handle it with the request_handler. Cables.Handler
This gives you full control over sending and recieving stream data.
For an example see Cables.Response.
Examples
iex> {:ok, cable} = Cables.new("https://nghttp2.org/")
...> {:ok, %Cables.Response{status: status}} = Cables.request(cable, :get, "/httpbin/get", Cables.Response, nil)
...> status
200
Send a piece of data. Make sure to use &send_final_data/3 to send the final chunk.
Send a piece of data and indicate that the request body has finished.