Skip to content

Instantly share code, notes, and snippets.

@cigrainger
Created June 15, 2023 15:26
Show Gist options
  • Save cigrainger/a8c876e0f11db16d2b5de15c65fdf351 to your computer and use it in GitHub Desktop.
Save cigrainger/a8c876e0f11db16d2b5de15c65fdf351 to your computer and use it in GitHub Desktop.

Mint closed

Mix.install([
  {:mint, "~> 1.5"},
  {:kino, "~> 0.9.4"}
])

Section

host = Kino.Input.text("Host")
user = Kino.Input.text("User")
password = Kino.Input.password("Password")

Kino.Layout.grid([host, user, password])
[host, user, password] = for var <- [host, user, password], do: Kino.Input.read(var)
{:ok, conn} = Mint.HTTP.connect(:http, host, 9200)
auth = "Basic #{Base.encode64("#{user}:#{password}")}"
{:ok, conn, request_ref} =
  Mint.HTTP.request(
    conn,
    "GET",
    "/publications/_count",
    [{"Authorization", auth}],
    ""
  )
receive do
  message ->
    case Mint.HTTP.stream(conn, message) do
      :unknown -> IO.inspect(message)
      {:ok, _conn, responses} -> IO.inspect(responses)
    end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment