Commit graph

387 commits

Author SHA1 Message Date
akhesacaro
e01188aaad min bound aeson 2 2021-11-18 11:56:32 +01:00
Gaël Deest
575aa70eca Cleanup 2021-11-18 10:11:45 +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
861cd4f997 Exclude quantified constraints code for GHCJS
QuantifiedConstraints isn't available for GHC 8.4 (where our GHCJS
version is still stuck).

We may need to take a drastic decision for GHCJS at some point.
2021-11-18 10:09:58 +01:00
Gaël Deest
b0b02f1948 Implement HasServer (NamedRoutes routes)
We define `ServerT (NamedRoutes api) m` as `api (AsServerT m)`, so that
the server of an record-defined API is a record of handlers.

The implementation piggy backs on the instance for “vanilla” servant
types with `(:<|>)`, using the `GServantProduct` for converting backd
and forth between the record / vanilla servers.

The main difficulty is that GHC needs to know that this operation is
legit, which can be expressed as the fact that:

```
GToServant (Rep (ServerT (NamedRoutes api))) m ~
ServerT (GToServant (Rep (api AsApi))) m
```

plus a few additional constraints.

This is easy enough for `route`, as we know that `m ~ Handler`. But in
the case of `hoistServerWithContext`, the two involved monads are
unknown ; in other words, this constraint needs to hold `forall m.`

Switching `-XQuantifiedConstraints` on is not sufficient, as our
constraints involve type families (`Rep` and `ServerT`). Our trick is to
use an intermediary typeclass, `GServer`, as a provider of evidence (in
the form of a `Dict`) that our constraints are indeed satisfied for a
particular monad.

The only instance of `GServer` is defined along with it, so it is
practically invisible to users.
2021-11-18 10:09:58 +01:00
Théophile Choutri
4e4ad495ef Change the license value to a valid SPDX identifier 2021-10-31 22:37:56 +01:00
Maxim Koltsov
70f6c49524
Get rid of Unicode in err404 example (#1478)
ServerError field errBody uses ByteString, whose IsString instance kills
Unicode, thus turning example into garbage. Changed it to simple ASCII
string, since Unicode art did not exactly correspond to 404 error
anyway.

Fixes #1371
2021-10-31 14:36:57 +03:00
akhesacaro
e56f0092d7 remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
akhesaCaro
6e5dffbb91 unsupporting GHC < 8.6.5, removing unecessary imports 2021-10-02 13:13:24 +02:00
Brandon Chinn
799537f82d
Add serveWithContextT, ServerContext (#1441)
servant-server: add serveWithContexT and ServerContext
2021-08-21 19:15:02 +02:00
Paolo Capriotti
19ec395e66
Avoid using SOP constructors directly (#1434)
This is a followup to #1420. It uses `respond` and `matchUnion`, with
the help of some type annotations, instead of the NS constructors from
SOP.
2021-07-13 10:10:30 -05:00
Maxim Koltsov
e2b897d3c0
Prepare 0.18.3 release (#1430) 2021-06-24 00:38:46 +03:00
Maxim Koltsov
61111178f0
Support GHC-9.0.1 2021-06-23 23:06:07 +02: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
Maxim Koltsov
507f0a4671
Allow hspec < 2.9
https://github.com/commercialhaskell/stackage/issues/6010
2021-05-14 12:34:04 +03:00
Bodigrim
27173c9223
Allow bytestring-0.11 (#1386) 2020-12-16 11:04:49 +01:00
Philipp Balzarek
7675e725d2
Bump base64-bytestring limit to 1.3 (#1382) 2020-12-11 00:32:16 +01:00
Matthias Fischmann
2f20c32704
Don't warn about necessary, expected type errors. 2020-12-06 16:03:19 +01:00
Maxim Koltsov
0ad2bd221a
Prepare 0.18.2 release (#1364) 2020-11-22 17:51:32 +03:00
Andrey Prokopenko
ce638027a8
Remove extra parameter from haddock section of Fragment instances (#1362) 2020-11-22 11:08:32 +01:00
Felix Yan
aa4f54e92e
Correct a typo in UVerb.hs (#1363) 2020-11-22 11:08:11 +01:00
Felix Yan
1d0b34df50
Allow QuickCheck 2.14 (#1359)
Builds fine and all tests pass.
2020-11-22 11:07:54 +01:00
Andrey Prokopenko
da0c83d318
Add URI fragment as a separate combinator (#1324) 2020-11-18 21:57:20 +03:00
Maxim Koltsov
4c72c08830
Update inter-library version constraints 2020-11-05 10:48:38 +03:00
Maxim Koltsov
bd698cad3b
Bump version in preparation for new release 2020-11-04 17:06:51 +03:00
Maxim Koltsov
9e4a97eb78
Loosen upper bound on wai-extra 2020-11-04 15:11:15 +03:00
fisx
c1105899f4
union verbs (#1314) 2020-10-31 20:45:46 +01:00
fisx
64f3543034
bump "tested-with" ghc versions. (#1350) 2020-10-25 14:24:06 +01:00
Felix Yan
264846a61f
Allow hspec-wai 0.11 (#1343)
Builds fine and all tests pass.
2020-10-01 10:16:27 +02:00
Brandon Chinn
e364470dd9
Fix docs: emptyAPIServer -> emptyServer (#1344) 2020-10-01 09:58:50 +02:00
Felix Yan
b4b649c8f4
Allow http-api-data 0.4.2
Builds fine and all tests pass here.
2020-08-30 15:26:48 +08:00
Matthias Fischmann
858fb6cce5
Fix: remove x-revision from servant-server.cabal. 2020-07-31 20:25:31 +02:00
Matthias Fischmann
6dcb29bada
Update changelogs. 2020-07-31 20:19:07 +02:00
Maxim Koltsov
d740c18992
Explicit export list in ErrorFormatter.hs 2020-07-30 19:05:46 +03:00
Maxim Koltsov
43cf589e0e
Bump version to 0.18 2020-07-30 19:03:58 +03:00
Maxim Koltsov
cb0224d063
Add 8.10.1 to tested-with, haskell-ci regenerate 2020-07-17 17:17:45 +03:00
Maxim Koltsov
1a09b1d3a4
Update GHC 8.8.x versions to 8.8.3 2020-07-17 17:10:31 +03:00
Maxim Koltsov
cb80fa6263
Add tests for custom error formatters 2020-07-17 17:10:31 +03: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
Leif Warner
0530671ad6
Allow newer versions of base, template-haskell, lens, & unliftio-core 2020-07-03 06:57:52 +02:00
Felix Yan
4b225c23d7
Allow aeson 1.5 in all components (#1309) 2020-06-12 15:02:39 -04: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
Felix Yan
a221320f5a
Allow base64-bytestring 1.1
Builds fine and all tests pass here.
2020-04-26 11:35:01 +08:00
Théophile Choutri
b3b3dc9f41 docs(generic): Improve the documentation for genericServerT
This commit adds an explanation and a link to the Servant Cookbook
to `genericServerT`.

Moreover, the `genericServer` and `genericServe`'s haddocks are
slightly edited to add a missing 'a'.
2020-03-04 15:53:37 +01:00
Oleg Grenrus
c15f550e1f Incorrect lower bound in servant-server 2020-01-23 22:26:02 +02:00
Oleg Grenrus
b519014f96 Update other changelogs 2020-01-23 13:43:19 +02:00
Oleg Grenrus
3bf4b100a8 Bump version to 0.17 2020-01-23 12:50:07 +02:00
Oleg Grenrus
d29b0cc8f1 Use GHC-8.8.2 on Travis 2020-01-21 16:52:20 +02:00
Oleg Grenrus
524b07224f Change build-type: Simple; run doctests on CI via haskell-ci
Don't use hspec-discover in tutorial,
so doctests work on CI
2020-01-10 01:07:31 +02:00
Ilia Rodionov
40582c40e4 add query rewriting tests and changelog item
add prs: #1249

add ps1249 changelog item
2020-01-09 15:08:24 +02:00