This commit introduces a `CaptureHint` type, which is passed as an extra
argument to the `CaptureRouter` and `CaptureAllRouter` constructors for
the `Router'` type.
`CaptureHint` values are then used in `routerLayout`, to display the
name and "type" of captured values (single or list), instead of just
"<capture>" previously.
N.B.:
Because the `choice` smart constructor for routers can aggregate
`Capture` combinators with different capture hints, the `Capture*Router`
constructors actually take a *list* of `CaptureHint`, instead of a
single one.
Trying to use `NamedRoutes` with `servant-auth-server` currently results
in hideous error messages such as:
```
app/Main.hs:50:7: error:
• No instance for (Servant.Auth.Server.Internal.AddSetCookie.AddSetCookies
('Servant.Auth.Server.Internal.AddSetCookie.S
('Servant.Auth.Server.Internal.AddSetCookie.S
'Servant.Auth.Server.Internal.AddSetCookie.Z))
(AdminRoutes (Servant.Server.Internal.AsServerT Handler))
(ServerT
(Servant.Auth.Server.Internal.AddSetCookie.AddSetCookieApi
(Servant.Auth.Server.Internal.AddSetCookie.AddSetCookieApi
(NamedRoutes AdminRoutes)))
Handler))
arising from a use of 'serveWithContext'
• In the expression: serveWithContext (Proxy @API) ctx RootAPI {..}
```
This is because we didn't teach it how to recurse along `NamedRoutes`
trees and sprinkle headers at the tip of each branch.
This commit adds a test case and fixes the issue. In the process, it
also implements `ThrowAll` for `NamedRoutes`, which was necessary for
the test to run, and should also prove convenient for users.
The issue is similar to the one in #1513:
```
src/Servant/Server/Internal.hs:824:10: error:
• Uninferrable type variable k0 in
type family equation right-hand side: (TypeError ...)
• In the type instance declaration for ‘ServerT’
In the instance declaration for
‘HasServer ((arr :: a -> b) :> sub) context’
|
824 | type ServerT (arr :> sub) _ = TypeError (PartialApplication HasServer arr)
|
```
This fix is similar to the one in #1514.
Close#1513.
GHC 9.2 needs explicit kind signature here, I don't really understand
why.
This kind signature is correct and not too restritive, because `HasLink`
is technically defined `class HasLink endpoint` which means that it is
infered as `k -> Constraint`. In the instance signature, we have
`HasLink ((arr :: a -> b) :> sub)`, so here the `k` is the same kind as
the one of `:>` which is not polykinded.
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)