-
Add NoContentVerb #1028 #1219 #1228
The NoContent
API endpoints should now use NoContentVerb
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 be Lenient
#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 the
type Either String CapturedType
, where Left err
represents
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 use
rawQueryString
. By using queryString
rather then rawQueryString
we can enable such rewritings.
-
servant servant-server Make packages build-type: Simple
#1263
We 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).
-
Streaming refactoring.
#991
#1076
#1077
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-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.
-
Drop support for GHC older than 8.0
#1008
#1009
-
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 Bitraversable
and other Bi-
instances for :<|>
#1032
-
servant Add PutCreated
method type alias
#1024
-
servant Add ToSourceIO (NonEmpty a)
instance
#988
-
Stream
takes a status code argument
-Stream method framing ctype a
+Stream method status framing ctype a
(#966
#972)
-
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
(#959)
-
Added NoFraming
streaming strategy
(#959)
-
servant-server File serving in polymorphic monad.
i.e. Generalised types of serveDirectoryFileServer
etc functions in
Servant.Utils.StaticFiles
(#953)
-
servant-server ReqBody
content type check is recoverable.
This allows writing APIs like:
ReqBody '[JSON] Int :> Post '[PlainText] Int
:<|> ReqBody '[PlainText] Int :> Post '[PlainText] Int
which is useful when handlers are subtly different,
for example may do less work.
(