Skip to content

Commit

Permalink
Add instance HasServer (EmptyAPI :> api) context (haskell-servant#1775)
Browse files Browse the repository at this point in the history
* Add instance HasServer (EmptyAPI :> api) context

* add changelog
  • Loading branch information
odr authored and theophile-scrive committed Aug 29, 2024
1 parent 2097bc7 commit d0237f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.d/1775
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
synopsis: Add instance `HasServer (EmptyAPI :> api) context`
prs: #1775
9 changes: 8 additions & 1 deletion servant-server/src/Servant/Server/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d0237f1

Please sign in to comment.