Commit Graph

164 Commits

Author SHA1 Message Date
Intolerable
a2e003367d
Add HasStatus instance for Headers (that defers StatusOf to underlying value) (#1649)
* Add HasStatus instance for Headers (that defers StatusOf to underlying value)

* changelog.d/1649
2023-02-14 23:28:57 +01:00
andremarianiello
751350ba9e
WithResource combinator for Servant-managed resources (#1630) 2022-12-29 19:00:47 +01:00
Guillaume Bouchard
a4194dc490
feat: Polymorphic Elem for Union (#1637)
Close https://github.com/haskell-servant/servant/issues/1590
2022-12-23 09:42:52 +01:00
Teo Camarasu
86c61c6dbd Update doctest to be compatible with newer GHC 2022-10-27 13:05:51 +01:00
Tom Sydney Kerckhove
036102af58
Evaluate NoContent before (not) rendering it. (#1587)
* Evaluate NoContent before rendering it, so it shows up as covered in coverage reports

* failing test as well

* test that NoContent gets rendered if it is not an exception

Co-authored-by: Tom Sydney Kerckhove <syd@cs-syd.eu>
2022-05-04 14:40:26 +02:00
Sven Tennie
c388c5e82c
Add HeadNoContent to Servant.API.Verbs (#1502)
As the head method isn't allowed to contain any response body, no
general Head Verb is added. (This may easily lead to wrong usages...)

(https://httpwg.org/specs/rfc7231.html#HEAD)
2022-01-06 13:02:57 +01:00
Giorgio Marinelli
29d2553e74
Derive HasClient good response status from Verb status (#1469) 2021-12-09 10:09:18 +01:00
Théophile Choutri
a975cfc361
Add details about AddHeaders instances (#1490)
* Add details about the instances of AddHeader

Also:

* Cleanup of extensions and imports
2021-11-30 23:52:06 +01:00
Gaël Deest
3ed24fdd90
Merge pull request #1289 from acondolu/master
Better errors for partially applied combinators
2021-11-18 10:51:30 +01:00
Gaël Deest
fca59556dd Code reorganization
Move `HasServer (NamedRoutes routes)` instance

The instance has been moved to `Servant.Server.Internal`, as the
instances for other combinators. It is necessary so that the instance
can be re-exported from `Servant.Server` without circular imports.

Otherwise, users have to import `Servant.Server.Generic` manually ;
forgetting to do so will produce confusing error messages about the
missing instance.

Move `HasClient (NamedRoutes routes)` instance

Moved so that the instance is made available when importing
`Servant.Client`, avoiding possibly confusing errors when
`Servant.Client.Generic` isn't imported.
2021-11-18 10:09:58 +01:00
Gaël Deest
65e3070cac Add NamedRoutes combinator
Allows users to directly embed APIs defined as records of routes into
vanilla Servant API types.

E.g.:

```haskell
data MyRoutes mode = MyRoutes
  { version :: mode :- Get '[JSON] Int
  , …
  }

type API = "prefix" :> NamedRoutes MyRoutes :<|> …
```

APIs can thus be recursively defined directly with Generic record types.
2021-11-18 10:09:58 +01:00
Andrea Condoluci
42b7d0eb9b Type-level errors for HasLink for invalid combinators 2021-11-15 21:40:36 +01:00
Joseph C. Sible
fea40bd0fc Enable FlexibleContexts in Servant.API.ContentTypes
Starting with GHC 9.2, UndecidableInstances no longer implies FlexibleContexts.
Add this extension where it's needed to make compilation succeed.
2021-10-30 23:26:21 -04:00
akhesaCaro
6e5dffbb91 unsupporting GHC < 8.6.5, removing unecessary imports 2021-10-02 13:13:24 +02:00
Maxim Koltsov
61111178f0
Support GHC-9.0.1 2021-06-23 23:06:07 +02:00
Alp
0c961f6ebb
Fix #1405 (#1429)
Request bodies are not really supposed to be used in GET requests.
2021-06-21 22:54:29 -05:00
Paolo Capriotti
0f9cc7eeec
Add response header support to UVerb (#1420)
* Use type wrapped in Headers h to generate response

This avoids having to define MimeRender instances for Headers.
2021-06-10 17:10:50 +02:00
fisx
448c444db6
Typo (#1416) 2021-04-23 10:37:48 +02:00
fisx
6ebb9e419e
Fix overlapping MimeRender instances (#1376) 2020-12-09 23:08:54 +01:00
Andrey Prokopenko
da0c83d318
Add URI fragment as a separate combinator (#1324) 2020-11-18 21:57:20 +03:00
Arian van Putten
339eec6a90
Fix overlapping instance for WithStatus (#1361)
We do not need the `ToJSON` instance for `WithStatus`
it would cause an overlap between:

```
ToJSON a => MimeRender JSON a
```

and

```
forall cty a.  MimeRendercty  a =>  MimeRender cty (WithStatus a)
```
and Servant just needs the `MimeRender` typeclass for it to work

* Add some more docs to the UVerb module

* cookbook/uverb: Change GHC versions

CI was complaining some version did not exist. Trying to bump
Also added 8.10.1

* doc/cookbook/uverb: Remove 8.4.4 from tested versions

CI was running into a cabal bug for some reason
2020-11-18 17:33:03 +01:00
fisx
c1105899f4
union verbs (#1314) 2020-10-31 20:45:46 +01:00
Maxim Koltsov
57f0b0b390
Make error messages from combinators configurable
Currently there is no way for Servant users to customize formatting of
error messages that arise when combinators can't parse URL or request
body, apart from reimplementing those combinators for themselves or
using middlewares.

This commit adds a possibility to specify custom error formatters
through Context.

Fixes #685
2020-07-17 17:10:31 +03:00
Nathan van Doorn
ff9da1cde4 Use GHC.TypeLits rather than TypeNats 2020-06-13 15:50:12 +01:00
Nathan van Doorn
6889d053c7 Add FlexibleInstances for earlier GHCs 2020-06-13 15:38:36 +01:00
Nathan van Doorn
a8184a2ee0 Add KnownStatus typeclass 2020-06-13 15:10:07 +01:00
Jan Hrcek
b9d8fbcdc1
Fix typos and grammar (#1304)
* Fix typos and grammar

* Remove redundant words, fix articles

* More language fixes

* More typo fixes and resolve TODO about missing links
2020-06-06 00:43:51 -04:00
Oleg Grenrus
8fc47edf99 Remove deprecated modules (end of 2019 is passed) 2020-01-23 13:14:24 +02:00
Jan Hrček
da365b1e47 Various haddock fixes 2019-11-12 09:29:35 +01:00
Catherine Galkina
b440af900b Implemented NoContentVerb and server instances for it 2019-09-29 14:18:13 +03:00
Oleg Grenrus
4fab471c29 Refactor servant-client(-core)
- Rename GenResponse to ResponseF (analogous to RequestF)
- add NFData Headers
- Make Request and Response bodies be SourceIO,
  i.e. move conversions into specific implementations
2019-02-06 12:15:20 +02:00
Domen Kožar
e7655d380a
Add NoContent instance for NFData 2018-11-27 16:41:31 +00:00
Oleg Grenrus
f1eb5f93a8 Fix issue #1011: NewlineFraming encodes newline after each element 2018-11-10 01:45:56 +02:00
Oleg Grenrus
3001ed7990 Add mods to StreamBody 2018-11-09 21:49:53 +02:00
Oleg Grenrus
21af9a4051 Tweak lookupResponseHeader docs 2018-11-08 18:36:31 +02:00
Oleg Grenrus
db80f41dee
Merge pull request #1064 from DanBurton/lookup-response-header
Add lookupResponseHeader
2018-11-08 18:36:09 +02:00
Oleg Grenrus
7634e08352 Make ComprehensiveAPI part of public API
We cannot simply tweak it, it will break tests of other packages.
Including packages not in this repository.
2018-11-06 13:35:47 +02:00
Oleg Grenrus
45c1cbdfd5 Refactor Stream stuff
- Introduce SourceT, which is simple variant of "correct `ListT`".
  There are another variants possible (like in `streaming`),
  but I'm not sure there's much real difference.

- Introduce `Codensity`. There's a flag if people don't want to depend
  on `kan-extensions`.

- `StreamGenerator` and `ResultStream` are both `SourceT`.
  `Stream` combinator in `servant-client` uses `Codensity` for CPS.

- Add servant-machines, servant-conduit, servant-pipes
- Add streaming cookbook: just code, no explanations.
- Add a script to run streaming 'benchmarks'
2018-11-05 15:48:47 +02:00
Dan Burton
e604b930dc
Add lookupResponseHeader 2018-10-28 01:36:40 -04:00
Domen Kožar
c7f616ea2d
ResponseHeaders: export GetHeaders' 2018-10-14 12:15:41 +01:00
Nathan van Doorn
7133e9dad2 Add bifunctors instances for Servant.API.Alt
These mirror the corresponding instances for (,)
2018-09-05 13:15:42 +01:00
messis
13b521eb90 Add PutCreated verb 2018-08-13 15:15:45 +02:00
Oleg Grenrus
cfade67c2f Cleanup pre-GHC-8.0 stuff 2018-07-11 01:39:38 +03:00
Oleg Grenrus
88f8d3b0d1 Merge servant-generic 2018-07-05 23:21:25 +03:00
Oleg Grenrus
f9bcc15d0b Apply stylish-haskell on all modules 2018-06-29 23:36:39 +03:00
Oleg Grenrus
2c02287b6b Move Servant.Utils.Links -> Servant.Links. Fixes #997. 2018-06-25 14:27:17 +03:00
Oleg Grenrus
dcc67f3089 Add FromResultStream/ToStreamGenerator [a] instances.
- Add Streaming endpoint to the comprehensive API.
- Rename BuildFromStream to FromResultStram
   - I'm tempted to rename everything in the Servant.API.Stream
     (add some prefixes, `header` is too good name to steal)

The TODO in `servant-docs` is left intentionally.
2018-06-24 21:52:09 +03:00
Oleg Grenrus
f53370b361
Merge pull request #966 from jvanbruegge/stream-code
Allow to specify a status for streaming endpoints
2018-06-09 08:42:54 +03:00
Oleg Grenrus
be42f3d608 Implement GetHeaders instances without overlapping 2018-06-08 15:10:38 +03:00
Jan van Brügge
dbbe9b7321 Allow to specify the status of streaming endpoints 2018-05-28 12:00:29 +02:00