haskell-servant / haskell-servant/servant
Basic support for HTTP conditional requests (RFC 7232)
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
An important feature of HTTP are conditional requests as specified in [RFC7232](https://tools.ietf.org/html/rfc7232).
Specifically, I'm interested in the Etag based pre-conditions, of which the most popular one IMO is the a) `if-match` and b) `if-none-match`, as these allow respectively, for a) for implementing simple transactional semantics to avoid lost-updates (i.e. update/modify/delete a resource only if its state expressed as Etag matches what the client assumes it to be in), as well as b) optimise service calls to only fetch data if there's new data to fetch, especially for services returning back 100KiBs or more worth of data this is significant, as well as for simplifying client-side logic which can choose to trust the Etag to decide equality.
Last year I mentioned this on `#servant`, and then I forgot about it again. So this time I'm filling an issue :-)
Btw, here's what @jkarni told me about a year ago:
```
[20:25:51] does servant have any support for ETags?
[20:26:09] I have some services where I can actually compute an etag
[22:57:57] hvr: servant doesn't support etags directly (aside from allowing manual request and response headers), but this seems like a fun combinator to implement - I could try sketching something out
[23:03:40] so maybe the API would be that the handler has type 'Handler (ETag, IO a)' (or 'Handler (ETag, Handler a)' rather than 'Handler a'?
[01:12:08] hvr: this is actually quite a bit more generally useful, I guess - even if you can't precompute the ETag for a If-None-Match response, you can still compute it after the fact to support If-Match concurrency patterns
```
Contributor guide
Assessment
This issue has not been assessed yet.