mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
* Update README.md * Add structured JSON production logging (#105) * Log requests and background failures (#107) * Document production logging and the VPS runbook
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
defmodule ChesstrainerWeb.Plugs.PutRequestId do
|
||||
@moduledoc """
|
||||
Copies `Plug.RequestId`'s request id into the session.
|
||||
|
||||
LiveView processes handle later events after the original HTTP request has
|
||||
finished. Keeping the id in the session lets `UserAuth.mount_current_scope/2`
|
||||
put it into `Logger.metadata/1`, so LiveView logs remain correlatable with the
|
||||
request that mounted them.
|
||||
"""
|
||||
|
||||
@behaviour Plug
|
||||
|
||||
import Plug.Conn
|
||||
|
||||
@impl true
|
||||
def init(opts), do: opts
|
||||
|
||||
@impl true
|
||||
def call(conn, _opts) do
|
||||
case conn.assigns[:request_id] do
|
||||
nil -> conn
|
||||
request_id -> put_session(conn, :request_id, request_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user