elixir - 谁能准确解释一下Plug.Conn中put_private的含义?

标签 elixir

  @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/

相关文章:

elixir - 带宏的动态标识符

elixir - 有没有相当于 Rails Console 的 Phoenix

Heroku/Elixir Phoenix 框架 - 私有(private) Gitlab 存储库的主机 key 验证失败

Elixir 配置供应商

Phoenix同表多对多

erlang - 尽力而为的 OTP 监督

ssl - 使用 Elixir 和 Erlang ssl 模块获取 SSL 证书

elixir - Elixir 中是否有类似于 Python 的 enumerate 的快捷方式?

Elixir :invalid_child_spec for supervised process. 不知道为什么

elixir - 这个 Elixir map 示例有什么问题?