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!
|
-- 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
|
## 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
|
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
|
, -- * Handlers for all standard combinators
|
||||||
HasServer(..)
|
HasServer(..)
|
||||||
, Server
|
, Server
|
||||||
|
, EmptyAPIServer
|
||||||
|
, emptyAPIServer
|
||||||
, Handler (..)
|
, Handler (..)
|
||||||
, runHandler
|
, runHandler
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import Data.Maybe (fromMaybe, mapMaybe)
|
||||||
import Data.Either (partitionEithers)
|
import Data.Either (partitionEithers)
|
||||||
import Data.String (fromString)
|
import Data.String (fromString)
|
||||||
import Data.String.Conversions (cs, (<>))
|
import Data.String.Conversions (cs, (<>))
|
||||||
import Data.Tagged (Tagged, untag)
|
import Data.Tagged (Tagged(..), untag)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Typeable
|
import Data.Typeable
|
||||||
import GHC.TypeLits (KnownNat, KnownSymbol, natVal,
|
import GHC.TypeLits (KnownNat, KnownSymbol, natVal,
|
||||||
|
@ -52,7 +52,7 @@ import Web.HttpApiData (FromHttpApiData, parseHeader,
|
||||||
parseUrlPieceMaybe,
|
parseUrlPieceMaybe,
|
||||||
parseUrlPieces)
|
parseUrlPieces)
|
||||||
import Servant.API ((:<|>) (..), (:>), BasicAuth, Capture,
|
import Servant.API ((:<|>) (..), (:>), BasicAuth, Capture,
|
||||||
CaptureAll, Verb,
|
CaptureAll, Verb, EmptyAPI,
|
||||||
ReflectMethod(reflectMethod),
|
ReflectMethod(reflectMethod),
|
||||||
IsSecure(..), Header, QueryFlag,
|
IsSecure(..), Header, QueryFlag,
|
||||||
QueryParam, QueryParams, Raw,
|
QueryParam, QueryParams, Raw,
|
||||||
|
@ -532,6 +532,16 @@ instance HasServer api context => HasServer (HttpVersion :> api) context where
|
||||||
route Proxy context subserver =
|
route Proxy context subserver =
|
||||||
route (Proxy :: Proxy api) context (passToServer subserver httpVersion)
|
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
|
-- | Basic Authentication
|
||||||
instance ( KnownSymbol realm
|
instance ( KnownSymbol realm
|
||||||
, HasServer api context
|
, HasServer api context
|
||||||
|
|
Loading…
Add table
Reference in a new issue