View Source ExTypesense.HttpClient (ExTypesense v0.7.3)
Http client for Typesense server.
Summary
Types
Functions
@spec api_key() :: String.t() | nil
Returns the Typesense's API key
Warning
Even if
api_key
is hidden inConnection
struct, this function will still return the key and accessible inside shell (assuming bad actors [pun unintended:/
] can get in as well).
@spec get_host() :: String.t() | nil
@spec get_options() :: Keyword.t()
@spec get_port() :: non_neg_integer() | nil
@spec get_scheme() :: String.t() | nil
@spec request(ExTypesense.Connection.t(), map()) :: {:ok, any()} | {:error, String.t()}
Command for making http requests.
Options
:body
Payload for passing as request body (defaults tonil
).:path
Request path.:method
Request method (e.g.:get
,:post
,:put
,:patch
,:delete
). Defaults to:get
.:query
Request query params (defaults to%{}
).:content_type
"Content-Type"
request header. Defaults to"application/json"
.
Examples
iex> connection = %ExTypesense.Connection{
...> host: "localhost",
...> api_key: "some_api_key",
...> port: "8108",
...> scheme: "http"
...> }
iex> HttpClient.request(connection, %{method: :post, path: "/collections", body: ExTypesense.TestSchema.Person})
{:ok,
[%{
"created_at" => 123456789,
"default_sorting_field" => "person_id",
"fields" => [...],
"name" => "persons",
"num_documents" => 0,
"symbols_to_index" => [],
"token_separators" => []
}]
}