ankh v0.8.1 Ankh.HTTP

Ankh HTTP public API

Link to this section Summary

Types

HTTP body

HTTP Header

HTTP Header name

HTTP Header value

HTTP Headers

Functions

Accepts an HTTP connection

Closes the underlying connection

Establishes an HTTP connection to a server

Reports a connection error

Sends a request to a server

Sends a response to a client request

Receives data form the the other and and returns responses

Link to this section Types

Link to this type

body()

body() :: iodata()

HTTP body

Link to this type

header()

header() :: {header_name(), header_value()}

HTTP Header

Link to this type

header_name()

header_name() :: String.t()

HTTP Header name

Link to this type

header_value()

header_value() :: String.t()

HTTP Header value

Link to this type

headers()

headers() :: [header()]

HTTP Headers

Link to this section Functions

Link to this function

accept(uri, socket, options \\ [])

accept(URI.t(), Ankh.Transport.t(), Ankh.Transport.options()) ::
  {:ok, Ankh.Protocol.t()} | {:error, any()}

Accepts an HTTP connection

After accepting the connection, stream will receive requests from the client and respond can be used to send replies.

Link to this function

close(protocol)

close(Ankh.Protocol.t()) :: :ok | {:error, any()}

Closes the underlying connection

Link to this function

connect(uri, options \\ [])

connect(URI.t(), keyword()) :: {:ok, Ankh.Protocol.t()} | {:error, any()}

Establishes an HTTP connection to a server

After establishing the connection, request can be user to send request to the server and stream can be used to receive receive responses.

Link to this function

error(protocol)

error(Ankh.Protocol.t()) :: :ok | {:error, any()}

Reports a connection error

Link to this function

request(protocol, request)

Sends a request to a server

Needs a connection to be established via connect beforehand.

Link to this function

respond(protocol, reference, response)

Sends a response to a client request

Needs a connection to be accepted via accept beforehand.

Link to this function

stream(protocol, msg)

stream(Ankh.Protocol.t(), any()) ::
  {:ok, Ankh.Protocol.t(), any()} | {:error, any()}

Receives data form the the other and and returns responses