From d0237f1edd7bd3ef88133ea9e4238df8f4ea3bf1 Mon Sep 17 00:00:00 2001 From: Dmitry Olshansky Date: Wed, 14 Aug 2024 15:13:36 +0300 Subject: [PATCH] Add instance HasServer (EmptyAPI :> api) context (#1775) * Add instance HasServer (EmptyAPI :> api) context * add changelog --- changelog.d/1775 | 2 ++ servant-server/src/Servant/Server/Internal.hs | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelog.d/1775 diff --git a/changelog.d/1775 b/changelog.d/1775 new file mode 100644 index 000000000..4bf712116 --- /dev/null +++ b/changelog.d/1775 @@ -0,0 +1,2 @@ +synopsis: Add instance `HasServer (EmptyAPI :> api) context` +prs: #1775 diff --git a/servant-server/src/Servant/Server/Internal.hs b/servant-server/src/Servant/Server/Internal.hs index 965c626f2..a2818d18b 100644 --- a/servant-server/src/Servant/Server/Internal.hs +++ b/servant-server/src/Servant/Server/Internal.hs @@ -641,7 +641,7 @@ instance -- -- The way the object is constructed from the extracted fields can be controlled by -- providing an instance on @'FromDeepQuery'@ --- +-- -- Example: -- -- > type MyApi = "books" :> DeepQuery "filter" BookQuery :> Get '[JSON] [Book] @@ -914,6 +914,13 @@ instance HasServer EmptyAPI context where hoistServerWithContext _ _ _ = retag +-- | Ignore @'EmptyAPI'@ as part of route in server handlers. +instance HasServer api context => HasServer (EmptyAPI :> api) context where + type ServerT (EmptyAPI :> api) m = ServerT api m + + route _ = route (Proxy :: Proxy api) + hoistServerWithContext _ = hoistServerWithContext (Proxy :: Proxy api) + -- | Basic Authentication instance ( KnownSymbol realm , HasServer api context