silkapp/rest — pull request #74 by AndrewRademacher (2014-10-15 04:34:23+00:00)
Title: Added support for writing static response headers to HTTP actions.

Awhile ago I noticed that there wasn't any documentation on how to set custom response headers in rest-core and made note of it in issue #59. I was unaware at the time that there wasn't a facility for setting custom response headers. Since I need this capability to support CORS, I've added a simple static header configuration that can be applied to any Handler, as shown below. The tooling that I have submitted does not allow you to set headers based on the input environment or on the generated output, but I have been unable to come up with a situation when that would be warranted. Though if there is interest in that functionality I am happy to look into what it would take to accomplish.

```haskell
get :: Handler WithInfo
get = defHead $ mkHandler (jsonO . someO) $ \e -> do
i <- ask
return $ SampleRes i

defHead :: Handler m -> Handler m
defHead = setResponseHeaders [("Access-Control-Allow-Origin-Test", "localhost:3000")]
```