haskell-servant / haskell-servant/servant

Document headers for ServantErr

Open
#660 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
2k
Forks
427
Avg merge
2d 23h
Merged PRs (30d)
5

Description

Currently, the [documentation](http://haskell-servant.readthedocs.io/en/stable/tutorial/Server.html#response-headers) for headers only mentions how to add a header to a request. This method is repeated in the [authentication](http://haskell-servant.readthedocs.io/en/stable/tutorial/Authentication.html#generalized-authentication) documentation, where it is mentioned besides a use of `throwError (err403 { errBody = "Invalid Cookie" })`.
On inspection of ServantErr, the `errHeaders` field is hard to miss, so one would assume that this can be used to add a header to the response, and the obvious way to do that would be to use `addHeader`.
This doesn't work, of course: although it seems to be possible to use the methods in `Servant.API.ResponseHeaders` to create a list of headers, it isn't obvious how one is supposed to do this. The easiest way to add a header to ServantErr is by importing `Network.HTTP.Types.Header` and using one of its helper methods to create the appropriate header.
This should be documented somewhere, as there are now two ways to add headers, one of which is undocumented, and one of which is nontrivial to deduce from the documentation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.