Skip to content

Commit 6ed2970

Browse files
authored
Plug.Conn.upgrade_adapter/3 doc updates (#1120)
1 parent d794055 commit 6ed2970

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/plug/conn.ex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ defmodule Plug.Conn do
13741374
this function is solely to allow an application to issue an upgrade request, not to manage how
13751375
a given protocol upgrade takes place or what APIs the application must support in order to serve
13761376
this updated protocol. For details in this regard, consult the documentation of the underlying
1377-
adapter (such a Plug.Cowboy or Bandit).
1377+
adapter (such a [Plug.Cowboy](https://hexdocs.pm/plug_cowboy) or [Bandit](https://hexdocs.pm/bandit)).
13781378
13791379
Takes an argument describing the requested upgrade (for example, `:websocket`), and an argument
13801380
which contains arbitrary data which the underlying adapter is expected to interpret in the
@@ -1383,12 +1383,13 @@ defmodule Plug.Conn do
13831383
If the upgrade is accepted by the adapter, the returned `Plug.Conn` will have a `state` of
13841384
`:upgraded`. This state is considered equivalently to a 'sent' state, and is subject to the same
13851385
limitation on subsequent mutating operations. Note that there is no guarantee or expectation
1386-
that the actual upgrade process is undertaken within this function; it is entirely possible that
1387-
the server will only do the actual upgrade later in the connection lifecycle.
1386+
that the actual upgrade process has succeeded, or event that it is undertaken within this
1387+
function; it is entirely possible (likely, even) that the server will only do the actual upgrade
1388+
later in the connection lifecycle.
13881389
1389-
If the adapter does not support the requested upgrade then this is a noop and the returned
1390-
`Plug.Conn` will be unchanged. The application can detect this and operate on the conn as it
1391-
normally would in order to indicate an upgrade failure to the client.
1390+
If the adapter does not support the requested protocol this function will raise an
1391+
`ArgumentError`. The underlying adapter may also signal errors in the provided arguments by
1392+
raising; consult the corresponding adapter documentation for details.
13921393
"""
13931394
@spec upgrade_adapter(t, atom, term) :: t
13941395
def upgrade_adapter(%Conn{adapter: {adapter, payload}, state: state} = conn, protocol, args)

0 commit comments

Comments
 (0)