servant-server
A family of combinators for defining webservices APIs and serving them
| LTS Haskell 24.17: | 0.20.3.0@rev:1 | 
| Stackage Nightly 2025-10-31: | 0.20.3.0@rev:1 | 
| Latest on Hackage: | 0.20.3.0@rev:1 | 
servant-server-0.20.3.0@sha256:10a429eea8e103484d86efbd9d0fee3e32c27901042a0f99398dc3dbeb0b50fc,6475Module documentation for 0.20.3.0
- Servant
- Servant.Server
- Servant.Server.Experimental
- Servant.Server.Generic
- Servant.Server.Internal
- Servant.Server.Internal.BasicAuth
- Servant.Server.Internal.Context
- Servant.Server.Internal.Delayed
- Servant.Server.Internal.DelayedIO
- Servant.Server.Internal.ErrorFormatter
- Servant.Server.Internal.Handler
- Servant.Server.Internal.ResponseRender
- Servant.Server.Internal.RouteResult
- Servant.Server.Internal.Router
- Servant.Server.Internal.RoutingApplication
- Servant.Server.Internal.ServerError
 
- Servant.Server.StaticFiles
- Servant.Server.UVerb
 
- Servant.Utils
 
- Servant.Server
servant-server

This library lets you implement an HTTP server with handlers for each endpoint of a servant API, handling most of the boilerplate for you.
Getting started
We’ve written a tutorial guide that introduces the core types and features of servant. After this article, you should be able to write your first servant webservices, learning the rest from the haddocks’ examples.
Changes
The latest version of this document is on GitHub.
Changelog for servant package contains significant entries for all core packages.
Package versions follow the Package Versioning Policy: in A.B.C, bumps to either A or B represent major versions.
0.20.3.0
Significant changes
- 
Remove -XStrictData from servant{,-server}’s cabal files #1780 #1781 The addition of -XStrictData to servant.cabal and servant-server.cabal reduced the laziness of routing, which would trigger unimplemented endpoints using errororundefined, despite the fact that these endpoints themselves were not queried.
Other changes
- 
Server-sent events (SSE) for client-side #1811 Implement Server-sent events (SSE) for the Servant client using a new combinator “ServerSentEvents”. The raw event messages, accumulated events and JSON-processed events can be exposed. 
- 
Integrate MultiVerb #1766 #1804 Expose MultiVerb, a more ergonomic way of defining endpoints that return many kinds of responses. Read the cookbook https://docs.servant.dev/en/master/cookbook/multiverb/MultiVerb.html 
- 
Add Host API combinator #1800 Adding a Host combinator allows servant users to select APIs according to the Host header provided by clients. 
- 
Add public re-export of renderCurlBasePath lens #1706 
- 
Remove GHC <= 8.10.7 from the support window #1778 
- 
Add Servant.API.Range type #1805 
- 
Add missing HasLink instance for DeepQuery #1784 
0.20.2
- 
Fix build of examples/greet.hs. Add “429 Too Many Requests” error. #1591 
- 
Full query string helpers #1604 This involves a new instance HasServer (QueryString :> api) context.
- 
Add MkHandlerpattern synonym #1732 #1733Add a bidirectional pattern synonym to construct Handler avalues fromIO (Either ServerError a)ones, and match in the other direction.
- 
Add instance HasServer (EmptyAPI :> api) context#1775
- 
Bugfix - CaptureAll produces [””] for empty paths due to trailing slash. #1243 #1516 CaptureAll resulted in [""]for empty paths due to trailing slash. Similar oddities occurred around these edge cases like"/"resulted in[]correctly, but"//"resulted in["", ""]. This patch simply eliminates the first""in the pathinfo list as taken from the wai response. This might break user code that relies on personal shims to solve the problem, however simply removing their workarounds should fix their code as the behavior is now sane.
0.20
- Add API docs for ServerT #1573
- Add Functor instance to AuthHandler. #1638
- Compatibility with GHC 9.6. #1680
0.19.2
Compatibility with GHC 9.4, see PR #1592.
0.19.1
- Add MonadFailinstance forHandlerwrt #1545
- Support GHC 9.2 #1525
- Add capture hints in Routertype for debug and display purposes [PR #1556] (https://github.com/haskell-servant/servant/pull/1556)
0.19
Significant changes
- Drop support for GHC < 8.6.
- Support GHC 9.0 (GHC 9.2 should work as well, but isn’t fully tested yet).
- Support Aeson 2 (#1475), which fixes a DOS vulnerability related to hash collisions.
- Add NamedRoutescombinator, making support for records first-class in Servant (#1388).
- Add custom type errors for partially applied combinators (#1289, #1486).
0.18.3
Significant changes
- Add response header support to UVerb (#1420)
Other changes
- Support GHC-9.0.1.
- Bump bytestring,hspecandbase64-bytestringdependencies.
0.18.2
Significant changes
- Support Fragmentcombinator.
0.18.1
Significant changes
- Union verbs
Other changes
- Bump “tested-with” ghc versions
- Allow newer dependencies
0.18
Significant changes
- 
Support for ghc8.8 (#1318, #1326, #1327) 
- 
Configurable error messages for automatic errors thrown by servant, like “no route” or “could not parse json body” (#1312, #1326, #1327) 
0.17
Significant changes
- 
Add NoContentVerb #1028 #1219 #1228 The NoContentAPI endpoints should now useNoContentVerbcombinator. The API type changes are usually of the kind- :<|> PostNoContent '[JSON] NoContent + :<|> PostNoContenti.e. one doesn’t need to specify the content-type anymore. There is no content. 
- 
Capturecan beLenient#1155 #1156You can specify a lenient capture as :<|> "capture-lenient" :> Capture' '[Lenient] "foo" Int :> GETwhich will make the capture always succeed. Handlers will be of the type Either String CapturedType, whereLeft errrepresents the possible parse failure.
- 
servant-server use queryString to parse QueryParam, QueryParams and QueryFlag #1249 #1262 Some APIs need query parameters rewriting, e.g. in order to support for multiple casing (camel, snake, etc) or something to that effect. This could be easily achieved by using WAI Middleware and modifying request’s Query. But QueryParam, QueryParams and QueryFlag userawQueryString. By usingqueryStringrather thenrawQueryStringwe can enable such rewritings.
- 
servant servant-server Make packages build-type: Simple#1263We used build-type: Custom, but it’s problematic e.g. for cross-compiling. The benefit is small, as the doctests can be run other ways too (though not so conveniently).
0.16.2
- singleton-bool-0.1.5(- SBoolis re-exported)- Add discreteBool :: Dec (a :~: b)(GHC-7.8+)
- Add Show,Eq,OrdSBool binstances.
 
- Add 
- dependencies update
0.16.1
- Use http-api-data-0.4.1(a part of its API is re-exported) #1181
0.16
- Rename ServantErrortoClientError,ServantErrtoServerError#1131
- servant-server Reorder HTTP failure code priorities #1103
- servant-server Re-organise internal modules #1139
- Allow network-3.0#1107
0.15
- 
Streaming refactoring. #991 #1076 #1077 The streaming functionality ( Servant.API.Stream) is refactored to useservant’s ownSourceIOtype (seeServant.Types.SourceTdocumentation), which replaces bothStreamGeneratorandResultStreamtypes.New conversion type-classes are ToSourceIOandFromSourceIO(replacingToStreamGeneratorandBuildFromStream). There are instances for conduit, pipes and machines in new packages: servant-conduit servant-pipes and servant-machines respectively.Writing new framing strategies is simpler. Check existing strategies for examples. This change shouldn’t affect you, if you don’t use streaming endpoints. 
- 
servant NewlineFraming encodes newline after each element (i.e last) #1079 #1011 
- 
servant Add lookupResponseHeader :: ... => Headers headers r -> ResponseHeader h a#1064
- 
servant-server Add MonadMask Handler#1068
- 
servant Export GetHeaders'#1052
- 
servant Add Bitraversableand otherBi-instances for:<|>#1032
- 
servant Add PutCreatedmethod type alias #1024
- 
servant Add ToSourceIO (NonEmpty a)instance #988
0.14.1
- 
Merge in servant-generic(by Patrick Chilton) intoservant(Servant.API.Generic),servant-client-code(Servant.Client.Generic) andservant-server(Servant.Server.Generic).
- 
servant-server Deprecate Servant.Utils.StaticUtils, useServant.Server.StaticUtils.
0.14
- 
Streamtakes a status code argument-Stream method framing ctype a +Stream method status framing ctype a
- 
ToStreamGeneratordefinition changed, so it’s possible to write an instance for conduits.-class ToStreamGenerator f a where - toStreamGenerator :: f a -> StreamGenerator a +class ToStreamGenerator a b | a -> b where + toStreamGenerator :: a -> StreamGenerator b(#959) 
- 
Added NoFramingstreaming strategy (#959)
- 
servant-server File serving in polymorphic monad. i.e. Generalised types of serveDirectoryFileServeretc functions inServant.Utils.StaticFiles(#953)
- 
servant-server ReqBodycontent type check is recoverable. This allows writing APIs like:ReqBody '[JSON] Int :> Post '[PlainText] Int :<|> ReqBody '[PlainText] Int :> Post '[PlainText] Intwhich is useful when handlers are subtly different, for example may do less work. (#937) 
0.13.0.1
- Support base-compat-0.10
0.13
0.12
Breaking changes
- Added hoistServermember to theHasServerclass, which isHasServerspecificenter. (#804)
0.11
Breaking changes
- Changed HasServerinstances forHeaderto throw 400 when parsing fails (#724)
- Added headersDblock toDelayed(#724)
Other changes
- Add err418,err422error codes (#739)
0.10
Breaking changes
- 
Handleris now an abstract datatype. Migration hint: changethrowEtothrowError. (#641)
- 
Changed HasServerinstances forQueryParamandQueryParamto throw 400 when parsing fails (#649)
Other changes
- 
Added paramsDblock toDelayed
- 
Add err422Unprocessable Entity (#646)
- 
Deprecate serveDirectoryand introduceserveDirectoryFileServer,serveDirectoryWebApp,serveDirectoryWebAppLookup,serveDirectoryEmbeddedandserveDirectoryWithwhich offer 4 default options and a more flexible one for serving static files. (#658)
- 
DelayedIOis an instance ofMonadResource, allowing safe resource handling. (#622 , #674 , #675)
0.7.1
- Remove module Servant.Server.Internal.Enter(https://github.com/haskell-servant/servant/pull/478)
- Support GHC 8.0
0.7
- The Routertype has been changed. Static router tables should now be properly shared between requests, drastically increasing the number of situations where servers will be able to route requests efficiently. FunctionslayoutandlayoutWithContexthave been added to visualize the router layout for debugging purposes. Test cases for expected router layouts have been added.
- If an endpoint is discovered to have a non-matching “accept header”, this is now a recoverable rather than a fatal failure, allowing different endpoints for the same route, but with different content types to be specified modularly.
- Export throwErrorfrom moduleServant
- Add Handlertype synonym
0.6.1
- If servers use the BasicAuthcombinator and receive requests with missing or invalid credentials, the resulting error responses (401 and 403) could be overwritten by subsequent alternative routes. NowBasicAuthusesFailFataland the error responses can’t be overwritten anymore.
0.6
- Query parameters that can’t be parsed result in a 400(was404).
0.5
- Add Configmachinery (https://github.com/haskell-servant/servant/pull/327). This is a breaking change, as the signatures of bothroute,serveand the typeclassHasServernow take an additional parameter.
- Support for the HttpVersion,IsSecure,RemoteHostandVaultcombinators
- Drop EitherTin favor ofExceptT
- Use http-api-datainstead ofServant.Common.Text
- Remove matrix params.
- Remove RouteMismatch.
- Redefined constructors of RouteResult.
- Added Delayedand related functions (addMethodCheck,addAcceptCheck,addBodyCheck,runDelayed)
- Added support for Basic Authentication
- Add generalized authentication support via the AuthServerDatatype family andAuthHandlerhandler
0.4.1
- Bump attoparsec upper bound to < 0.14
- Bump wai-app-static upper bound to < 3.2
- Bump either upper bound to < 4.5
0.4
- Deletenow is like- Get,- Post,- Put, and- Patchand returns a response body
- Add a RouteMismatchconstructor for arbitrary HTTP response codes (https://github.com/haskell-servant/servant-server/pull/22)
- Add support for the Patchcombinator
- Support for Accept/Content-typeheaders and for the content-type aware combinators in servant-0.4
- Export toApplicationfromServant.Server(https://github.com/haskell-servant/servant-server/pull/29)
- Support other Monads than just EitherT (Int, String) IO(https://github.com/haskell-servant/servant-server/pull/21)
- Make methods return status code 204 if they return () (https://github.com/haskell-servant/servant-server/issues/28)
- Add server support for response headers
- Use ServantErrinstead of(Int,String)inEitherThandlers
- Add errXXXfunctions for HTTP errors with sensible default reason strings
- Add enterfunction for applying natural transformations to handlers
0.2.4
- Added support for matrix parameters, see e.g. http://www.w3.org/DesignIssues/MatrixURIs.html
- Add support for serializing based on Accept header (https://github.com/haskell-servant/servant-server/issues/9)
- Ignore trailing slashes (https://github.com/haskell-servant/servant-server/issues/5)
0.2.3
- Fix consuming request body issue (https://github.com/haskell-servant/servant/issues/3)
- Make code sample in Servant.Server complete
