servant-http-streams

Automatic derivation of querying functions for servant

http://docs.servant.dev/

LTS Haskell 23.27:0.20.2@rev:1
Stackage Nightly 2025-07-12:0.20.2@rev:1
Latest on Hackage:0.20.2@rev:1

See all snapshotsservant-http-streams appears in

BSD-3-Clause licensedbyServant Contributors
Maintained by[email protected]
This version can be pinned in stack with:servant-http-streams-0.20.2@sha256:d67ad1f246eca8575f26be92044b697faad75b331178845ab1480679aca03ecc,4525

Module documentation for 0.20.2

servant-client

servant

This library lets you automatically derive Haskell functions that let you query each endpoint of aservant webservice.

Example

{-# LANGUAGE DataKinds #-}{-# LANGUAGE TypeOperators #-}import Data.Proxyimport Data.Textimport Servant.APIimport Servant.HttpStreamstype Book = Texttype MyApi = "books" :> Get '[JSON] [Book] -- GET /books        :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book -- POST /booksmyApi :: Proxy MyApimyApi = Proxy-- 'client' allows you to produce operations to query an API from a client.postNewBook :: Book -> ClientM BookgetAllBooks :: ClientM [Book](getAllBooks :<|> postNewBook) = client myApi-- the IOException happens already in withClientEnvIOmain' :: IO ()main' = do    let burl = BaseUrl Http "localhost" 8081 ""    withClientEnvIO burl $ \env -> do        res <- runClientM getAllBooks env        case res of            Left err -> putStrLn $ "Error: " ++ show err            Right books -> print booksmain :: IO ()main = return ()

Changes

The latest version of this document is on GitHub.Changelog forservant package contains significant entries for all core packages.

0.20.2

  • Compatibility with newer dependencies and GHC versions

0.20

  • Compatibility with GHC series 9.2, 9.4, 9.6

0.18.4

Significant changes

  • servant-client /servant-client-core /servant-http-streams:Fix erroneous behavior, where only 2XX status codes would be consideredsuccessful, irrelevant of the status parameter specified by the verbcombinator. (#1469)

0.18.3

Other changes

  • Support GHC-9.0.1.
  • Fix test suite running in CI.
  • Bumpbytestring andhspec dependencies.

0.18.2

Significant changes

  • Supportservant-client-core 0.18.2.

0.18.1

Significant changes

  • Union verbs

Other changes

  • Bump “tested-with” ghc versions

0.18

Significant changes

  • Support for ghc8.8 (#1318, #1326, #1327)

0.17

Significant changes

  • Add NoContentVerb#1028#1219#1228

    TheNoContent API endpoints should now useNoContentVerb combinator.The API type changes are usually of the kind

    - :<|> PostNoContent '[JSON] NoContent+ :<|> PostNoContent

    i.e. one doesn’t need to specify the content-type anymore. There is no content.

  • Capture can beLenient#1155#1156

    You can specify a lenient capture as

    :<|> "capture-lenient"  :> Capture' '[Lenient] "foo" Int :> GET

    which will make the capture always succeed. Handlers will be of thetypeEither String CapturedType, whereLeft err representsthe possible parse failure.

Other changes

  • servant-clientservant-client-coreservant-http-streams Fix Verb with headers checking content type differently#1200#1204

    ForVerbs with responseHeaders, the implementation didn’t checkfor the content-type of the response. Now it does.

  • servant-clientservant-http-streamsHasClient instance forStream withHeaders#1170#1197

  • servant-client Redact the authorization header in Show and exceptions#1238

0.16.0.1

  • Allowbase-compat-0.11

0.16

  • Initial release