View Source K8s.Client.Provider behaviour (k8s v2.0.0-rc.0)
HTTP Request / Response provider behaviour
Link to this section Summary
Callbacks
Perform HTTP requests
Perform HTTP requests and stream response
Perform HTTP requests
Perform Websocket requests and stream response
Functions
Generates HTTP headers from K8s.Conn.RequestOptions
Link to this section Types
@type error_t() :: {:error, K8s.Client.APIError.t() | K8s.Client.HTTPError.t()}
@type stream_chunk_t() :: {:data | binary()} | {:status, integer()} | {:headers, headers()} | {:error, K8s.Client.HTTPError.t()} | :done
@type stream_response_t() :: stream_success_t() | error_t()
@type stream_success_t() :: {:ok, Enumerable.t(stream_chunk_t())}
@type websocket_response_t() :: websocket_success_t() | error_t()
Link to this section Callbacks
@callback request( method :: atom(), uri :: URI.t(), body :: binary(), headers :: list(), http_opts :: keyword() ) :: response_t()
Perform HTTP requests
@callback stream( method :: atom(), uri :: URI.t(), body :: binary(), headers :: list(), http_opts :: keyword() ) :: stream_response_t()
Perform HTTP requests and stream response
@callback websocket_request( uri :: URI.t(), headers :: list(), http_opts :: keyword() ) :: websocket_response_t()
Perform HTTP requests
@callback websocket_stream( uri :: URI.t(), headers :: list(), http_opts :: keyword() ) :: stream_response_t()
Perform Websocket requests and stream response
Link to this section Functions
@spec headers(K8s.Conn.RequestOptions.t()) :: keyword()
Generates HTTP headers from K8s.Conn.RequestOptions
- Adds
{:Accept, "application/json"}
to all requests if the header is not set.
examples
Examples
Sets Content-Type
to application/json
iex> opts = %K8s.Conn.RequestOptions{headers: [Authorization: "Basic AF"]}
...> K8s.Client.HTTPProvider.headers(opts)
[Accept: "application/json", Authorization: "Basic AF"]