@spec put_private(t, atom, term) :: t
def put_private(%Conn{private: private} = conn, key, value) when is_atom(key) do
%{conn | private: Map.put(private, key, value)}
end
最佳答案
The docs做得很好:
Assigns a new private key and value in the connection.
This storage is meant to be used by libraries and frameworks to avoid writing to the user storage (the :assigns field). It is recommended for libraries/frameworks to prefix the keys with the library name.
关于elixir - 谁能准确解释一下Plug.Conn中put_private的含义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37411574/