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.
The streaming functionality (Servant.API.Stream) is refactored to use
servant’s own SourceIO type (see Servant.Types.SourceT documentation),
which replaces both StreamGenerator and ResultStream types.
New conversion type-classes are ToSourceIO and FromSourceIO
(replacing ToStreamGenerator and BuildFromStream).
There are instances for conduit, pipes and machines in new packages:
servant-conduitservant-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.
Merge in servant-generic (by Patrick Chilton)
into servant (Servant.API.Generic),
servant-client-code (Servant.Client.Generic)
and servant-server (Servant.Server.Generic).
servant-server Deprecate Servant.Utils.StaticUtils, use Servant.Server.StaticUtils.
0.14
Stream takes a status code argument
-Stream method framing ctype a
+Stream method status framing ctype a
ToStreamGenerator definition 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
Deprecate serveDirectory and introduce serveDirectoryFileServer,
serveDirectoryWebApp, serveDirectoryWebAppLookup, serveDirectoryEmbedded
and serveDirectoryWith which offer 4 default options and a more flexible
one for serving static files.
(#658)
DelayedIO is an instance of MonadResource, allowing safe resource handling.
(#622
, #674
, #675)
The Router type 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. Functions layout and layoutWithContext have 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 throwError from module Servant
Add Handler type synonym
0.6.1
If servers use the BasicAuth combinator and receive requests with missing or
invalid credentials, the resulting error responses (401 and 403) could be
overwritten by subsequent alternative routes. Now BasicAuth uses FailFatal
and the error responses can’t be overwritten anymore.
0.6
Query parameters that can’t be parsed result in a 400 (was 404).