Skip to content

Commit

Permalink
Uses in the doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobarauna committed Jun 3, 2024
1 parent f88c377 commit e93ed92
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/kino/proxy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,19 @@ defmodule Kino.Proxy do
>
> ```elixir
> Kino.Proxy.listen(fn conn ->
> api_token = "my-secret-api-token"
>
> case Plug.Conn.get_req_header(conn, "authorization") do
> ["Bearer " <> ^api_token] ->
> Plug.Conn.send_resp(conn, 200, "hello")
> expected_token = "my-secret-api-token"
>
> with ["Bearer " <> user_token] <- Plug.Conn.get_req_header(conn, "authorization"),
> true <- Plug.Crypto.secure_compare(user_token, expected_token) do
> Plug.Conn.send_resp(conn, 200, "hello")
> else
> _ ->
> conn
> |> Plug.Conn.put_resp_header("www-authenticate", "Bearer")
> |> Plug.Conn.send_resp(401, "Unauthorized")
> end
> end)
> ```
"""

@doc """
Expand Down

0 comments on commit e93ed92

Please sign in to comment.