Elixir 在Phoenix中设置Plug.Static头文件
我正在尝试将标题Connection:Keep Alive放在lib/app/endpoint.ex中:Elixir 在Phoenix中设置Plug.Static头文件,elixir,phoenix-framework,plug,Elixir,Phoenix Framework,Plug,我正在尝试将标题Connection:Keep Alive放在lib/app/endpoint.ex中: plug Plug.Static, at: "/", from: :app, gzip: true, only: ~w(css fonts images js favicon.ico robots.txt), etag_generation: {}, cache_control_for_etags: "public, max-age=3153600", headers:
plug Plug.Static,
at: "/", from: :app, gzip: true,
only: ~w(css fonts images js favicon.ico robots.txt),
etag_generation: {},
cache_control_for_etags: "public, max-age=3153600",
headers: %{"connection" => "keep-alive"}
但是当我运行curl-I-k-H“接受编码:gzip”时http://localhost:4000
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 24 Feb 2017 11:34:37 GMT
content-encoding: gzip
content-length: 5613
set-cookie: _app_key=...; path=/; HttpOnly
content-type: text/html; charset=utf-8
cache-control: max-age=0, private, must-revalidate
x-request-id: aafhn9sq18vpajadu1h7709vmb1f4jrg
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
它不会返回标题:connection:keep-alive
这是正常的还是我弄乱了什么?
Plug.Static
不能服务于您的主页。您应该在http://localhost:4000/robots.txt
(如果存在)和其他静态文件。是的,谢谢@Dogbert,但是我如何在主页中也这样做呢?最简单的方法是编写一个调用put\u resp\u header
的插件,并将该插件添加到router.ex