Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell Scotty:设置自定义标题(x帧选项)_Haskell_Scotty_Haskell Wai - Fatal编程技术网

Haskell Scotty:设置自定义标题(x帧选项)

Haskell Scotty:设置自定义标题(x帧选项),haskell,scotty,haskell-wai,Haskell,Scotty,Haskell Wai,哈斯克尔新手在这里 在我的haskell端项目中,我使用scotty来提供一些动态生成的html页面。问题在于,由于“x-frame-options”标题设置为“SAMEORIGIN”,因此无法在iframe内打开页面 如何将标题更改为其他内容?我想为所有回复设置标题。有没有一个中间件可以做到这一点 谢谢 您可以定义自己的中间件,将此头添加到每个响应中(所有必要的工具都可以在中获得): 然后在scotty应用程序中使用它: main = scotty 6000 $ do middleware

哈斯克尔新手在这里

在我的haskell端项目中,我使用scotty来提供一些动态生成的html页面。问题在于,由于“x-frame-options”标题设置为“SAMEORIGIN”,因此无法在iframe内打开页面

如何将标题更改为其他内容?我想为所有回复设置标题。有没有一个中间件可以做到这一点


谢谢

您可以定义自己的中间件,将此头添加到每个响应中(所有必要的工具都可以在中获得):

然后在scotty应用程序中使用它:

main = scotty 6000 $ do
  middleware addFrameHeader
  get "/" (text "hello")
通过
curl
我们可以看到它包含在响应中:

> curl --include localhost:6000
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Thu, 19 Jan 2017 19:22:57 GMT
Server: Warp/3.2.8
X-Frame-Options: whatever
Content-Type: text/plain; charset=utf-8

hello
> curl --include localhost:6000
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Thu, 19 Jan 2017 19:22:57 GMT
Server: Warp/3.2.8
X-Frame-Options: whatever
Content-Type: text/plain; charset=utf-8

hello