Skip to content

Commit 012cd8a

Browse files
authored
Add instance HasServer (EmptyAPI :> api) context (#1775)
* Add instance HasServer (EmptyAPI :> api) context * add changelog
1 parent 45e031e commit 012cd8a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

changelog.d/1775

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
synopsis: Add instance `HasServer (EmptyAPI :> api) context`
2+
prs: #1775

servant-server/src/Servant/Server/Internal.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ instance
641641
--
642642
-- The way the object is constructed from the extracted fields can be controlled by
643643
-- providing an instance on @'FromDeepQuery'@
644-
--
644+
--
645645
-- Example:
646646
--
647647
-- > type MyApi = "books" :> DeepQuery "filter" BookQuery :> Get '[JSON] [Book]
@@ -914,6 +914,13 @@ instance HasServer EmptyAPI context where
914914

915915
hoistServerWithContext _ _ _ = retag
916916

917+
-- | Ignore @'EmptyAPI'@ as part of route in server handlers.
918+
instance HasServer api context => HasServer (EmptyAPI :> api) context where
919+
type ServerT (EmptyAPI :> api) m = ServerT api m
920+
921+
route _ = route (Proxy :: Proxy api)
922+
hoistServerWithContext _ = hoistServerWithContext (Proxy :: Proxy api)
923+
917924
-- | Basic Authentication
918925
instance ( KnownSymbol realm
919926
, HasServer api context

0 commit comments

Comments
 (0)