Add instance HasServer EmptyAPI
This commit is contained in:
parent
8a16f47fba
commit
94483d586c
3 changed files with 23 additions and 2 deletions
|
@ -1020,6 +1020,15 @@ serverFor = error "..."
|
|||
-- or the mailing list if you get stuck!
|
||||
```
|
||||
|
||||
TODO prose
|
||||
|
||||
``` haskell
|
||||
type CombinedAPI2 = CombinedAPI :<|> EmptyAPI
|
||||
|
||||
server11 :: Server CombinedAPI2
|
||||
server11 = server10 :<|> emptyAPIServer
|
||||
```
|
||||
|
||||
## Using another monad for your handlers
|
||||
|
||||
Remember how `Server` turns combinators for HTTP methods into `Handler`? Well, actually, there's more to that. `Server` is actually a
|
||||
|
|
|
@ -17,6 +17,8 @@ module Servant.Server
|
|||
, -- * Handlers for all standard combinators
|
||||
HasServer(..)
|
||||
, Server
|
||||
, EmptyAPIServer
|
||||
, emptyAPIServer
|
||||
, Handler (..)
|
||||
, runHandler
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import Data.Maybe (fromMaybe, mapMaybe)
|
|||
import Data.Either (partitionEithers)
|
||||
import Data.String (fromString)
|
||||
import Data.String.Conversions (cs, (<>))
|
||||
import Data.Tagged (Tagged, untag)
|
||||
import Data.Tagged (Tagged(..), untag)
|
||||
import qualified Data.Text as T
|
||||
import Data.Typeable
|
||||
import GHC.TypeLits (KnownNat, KnownSymbol, natVal,
|
||||
|
@ -52,7 +52,7 @@ import Web.HttpApiData (FromHttpApiData, parseHeader,
|
|||
parseUrlPieceMaybe,
|
||||
parseUrlPieces)
|
||||
import Servant.API ((:<|>) (..), (:>), BasicAuth, Capture,
|
||||
CaptureAll, Verb,
|
||||
CaptureAll, Verb, EmptyAPI,
|
||||
ReflectMethod(reflectMethod),
|
||||
IsSecure(..), Header, QueryFlag,
|
||||
QueryParam, QueryParams, Raw,
|
||||
|
@ -532,6 +532,16 @@ instance HasServer api context => HasServer (HttpVersion :> api) context where
|
|||
route Proxy context subserver =
|
||||
route (Proxy :: Proxy api) context (passToServer subserver httpVersion)
|
||||
|
||||
data EmptyAPIServer = EmptyAPIServer
|
||||
|
||||
emptyAPIServer :: Server EmptyAPI
|
||||
emptyAPIServer = Tagged EmptyAPIServer
|
||||
|
||||
instance HasServer EmptyAPI context where
|
||||
type ServerT EmptyAPI m = Tagged m EmptyAPIServer
|
||||
|
||||
route Proxy _ _ = StaticRouter mempty mempty
|
||||
|
||||
-- | Basic Authentication
|
||||
instance ( KnownSymbol realm
|
||||
, HasServer api context
|
||||
|
|
Loading…
Reference in a new issue