elp*_*dev 2 elixir phoenix-framework
有没有办法读取和呈现位于控制器服务器上另一部分的静态html文件?我不打算通过静态页面功能重定向或提供此页面.
你应该用Plug.Conn.send_file/5它.此函数将比将整个文件读入内存更有效地发送文件内容,然后使用Phoenix.Controller.html/2以下命令发送:
conn
|> put_resp_header("content-type", "text/html; charset=utf-8")
|> Plug.Conn.send_file(200, "/path/to/html")
Run Code Online (Sandbox Code Playgroud)
请注意,我必须手动添加content-type标头以获得与之相同的行为Phoenix.Controller.html/2.
| 归档时间: |
|
| 查看次数: |
1797 次 |
| 最近记录: |