haskell-servant / haskell-servant/servant

NoContent limitations

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

Description

As far as I understand, it is currently impossible to use `NoContent`:

- to return an empty body with a status code different from 204,
- to return empty bodies from a `UVerb` endpoint.

We have worked around these limitations in https://github.com/wireapp/wire-server by introducing a type:
```
data EmptyResult (s :: Nat) = EmptyResult
```
and adding some special `HasServer` (and `HasClient`) instances for `EmptyResult` with an empty list of content types for both `Verb` and `UVerb`.

*[There is still the limitation that is not possible to return an empty body for *some* of the possible results of a `UVerb`, but not all, because then the list of content types is not empty. This stems from a limitation with `UVerb` itself, namely that the content types are fixed, and cannot depend on the result of the handler. I'm not sure if anything can be done about that, short of completely redesigning `UVerb`. Maybe this belongs to a separate issue.]*

Am I missing some other potential solutions? Would it make sense to submit a PR with the workaround above? If so, should `NoContent` be removed, as it would be superseded by `EmptyResult 204`?

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.