servant-rawm

Embed a raw 'Application' in a Servant API

https://github.com/cdepillabout/servant-rawm

Version on this page:0.3.2.0
LTS Haskell 22.14:1.0.0.0
Stackage Nightly 2024-03-28:1.0.0.0
Latest on Hackage:1.0.0.0

See all snapshots servant-rawm appears in

BSD-3-Clause licensed by Dennis Gosnell
Maintained by [email protected]
This version can be pinned in stack with:servant-rawm-0.3.2.0@sha256:aa291263da8c4eca948df8e9d03344e48dacac0c148e06289de5a4373a778276,5415

Servant.RawM

Build Status Hackage Stackage LTS Stackage Nightly BSD3 license

servant-rawm provides a way to embed a WAI Application in a Servant handler. It is more convenient and powerful than the Raw type provided by servant.

See the Haddocks on Hackage for servant-rawm for an explanation of how to use the RawM type.

Example

There is code for an example server, client, and documentation located in example/. The following section describes how to run the example executables.

Building

The example executables can be built with the following command:

$ stack build --flag servant-rawm:buildexample

Server

After building, the server can be run with the following command:

$ stack exec -- servant-rawm-example-server

This runs a server on port 8201 serving files in example/files/.

It can be accessed from curl like the following:

$ curl http://localhost:8201/serve-directory/foo.txt
This is an example text file.

Client

After building, the client can be run like the following:

$ stack exec -- servant-rawm-example-client
Successfully got file ./example/files/foo.txt:

This is an example text file.

Documentation

After building, the documentation can be generated like the following. This is documentation for the API defined in example/Api.hs:

$ stack exec -- servant-rawm-example-docs
...

Changes

0.3.2.0

0.3.1.0

  • Update to work with servant-0.16 #10. Thanks @vlatkoB!

0.3.0.0

  • Update to work with the latest version of Servant (0.14) and remove support from older versions of Servant.
  • Remove support from Stackage LTS versions older than 12.

0.2.0.2

  • Add missing test file to extra-source-files in the cabal file.

0.2.0.1

  • Add tests and more documentation.

0.2.0.0

  • (commit 30a2cd48488d) Add a phantom type to RawM to allow the user to change the output documentation.
  • (commit 30a2cd48488d) Add a HasDocs instance for RawM that uses the HasDocs instance for the phantom type.

0.1.0.0

  • Initial release.