Skip to content

Commit

Permalink
Document socket session options at runtime (#2715)
Browse files Browse the repository at this point in the history
  • Loading branch information
aerosol committed Jun 28, 2023
1 parent 8ce661e commit 8fedc69
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/phoenix_live_view/socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ defmodule Phoenix.LiveView.Socket do
socket "/live", MyAppWeb.UserSocket,
websocket: [connect_info: [session: @session_options]]
If you require session options to be set at runtime, you can use
an MFA tuple. The function it designates must return a keyword list.
socket "/live", MyAppWeb.UserSocket,
websocket: [connect_info: [session: {__MODULE__, :runtime_opts, []}]]
# ...
def runtime_opts() do
Keyword.put(@session_options, :domain, host())
end
"""
use Phoenix.Socket

Expand Down

0 comments on commit 8fedc69

Please sign in to comment.