haskell-servant / haskell-servant/servant

NoContent and Accept

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

Description

If I'm understanding correctly, it seems that if you're creating an endpoint that does not take a body, NoContent would be an appropricate content type to use since you can't use an empty list. However, NoContent does not have any sensible `Accept` instance, nor a reasonable `MimeUnrender`. For MimeUnrender, it seems clear that an instance for `()` which always succeeds would be appropriate. However, for `Accept`, there is isn't really a nullary mime type to indicate nothing. The [specs](https://www.w3.org/Protocols/HTTP/HTRQ_Headers.html) seem to indicate that Accept is optional but that clients should assume the endpoint accepts both `text/plain` and `text/html`.

So the question:
1. Would you accept a PR implementing `instance MimeUnrender NoContent ()`?
2. What should we do about accept? It seems like the semantically correct thing is to make `Accept` not require a specific mime type since it isn't required. The pragmatic approach that would disturb less code would seem to be to accept `text/plain` and `text/html` for `NoContent` as per the spec's rules about defaulting, possibly at the cost of producing a confusing `Accept`.

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.