https://github.com/cdepillabout/servant-rawm
Effectful Raw handler for Servant servers.
https://github.com/cdepillabout/servant-rawm
hacktoberfest haskell raw servant
Last synced: 10 months ago
JSON representation
Effectful Raw handler for Servant servers.
- Host: GitHub
- URL: https://github.com/cdepillabout/servant-rawm
- Owner: cdepillabout
- License: bsd-3-clause
- Created: 2017-09-25T06:54:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-03-16T02:21:34.000Z (about 5 years ago)
- Last Synced: 2025-07-15T14:11:18.549Z (11 months ago)
- Topics: hacktoberfest, haskell, raw, servant
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/servant-rawm
- Size: 197 KB
- Stars: 16
- Watchers: 4
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Servant.RawM
[](https://github.com/cdepillabout/servant-rawm/actions/workflows/ci.yml)
[](https://hackage.haskell.org/package/servant-rawm)
[](http://stackage.org/lts/package/servant-rawm)
[](http://stackage.org/nightly/package/servant-rawm)

`servant-rawm` provides a way to embed a WAI
[`Application`](https://hackage.haskell.org/package/wai-3.2.1.1/docs/Network-Wai.html#t:Application)
in a Servant handler. It is more convenient and powerful than the
[`Raw`](https://hackage.haskell.org/package/servant-0.11/docs/Servant-API-Raw.html#t:Raw)
type provided by [`servant`](https://hackage.haskell.org/package/servant).
See the
[Haddocks on Hackage for `servant-rawm`](https://hackage.haskell.org/package/servant-rawm/docs/Servant-RawM.html)
for an explanation of how to use the
[`RawM`](https://hackage.haskell.org/package/servant-rawm/docs/Servant-RawM.html#t:RawM)
type.
After `servant-rawm` 1.0.0.0, the implementations of the `RawM` endpoint are
divided into `servant-rawm-client`, `servant-rawm-docs`, and
`servant-rawm-server` to avoid introducing unnecessary dependencies and reduce
the compilation overhead.
You will need to add either of the implementations to your dependencies, and
import the corresponding implementation (`Servant.RawM.Server`,
`Servant.RawM.Client`, or `Servant.RawM.Docs`) for the `RawM` endpoint to
function correctly.
## Example
There is code for an example server, client, and documentation located
in [`servant-rawm-examples-and-tests/example/`](servant-rawm-examples-and-tests/example/). The following section describes how to run the
example executables.
### Building
The example executables can be built with the following command:
```sh
$ stack build servant-rawm-examples-and-tests
```
### Server
After building, the server can be run with the following command:
```sh
$ stack exec -- servant-rawm-example-server
```
This runs a server on port 8201 serving files
in [`servant-rawm-examples-and-tests/example/files/`](servant-rawm-examples-and-tests/example/files/).
It can be accessed from `curl` like the following:
```sh
$ curl http://localhost:8201/serve-directory/foo.txt
This is an example text file.
```
### Client
After building and running the server, the client can be run like the following:
```sh
$ 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
[servant-rawm-examples-and-tests/example/Api.hs](servant-rawm-examples-and-tests/example/Api.hs):
```sh
$ stack exec -- servant-rawm-example-docs
...
```
## Maintainers
- [@cdepillabout](https://github.com/cdepillabout)
- [@Krasjet](https://github.com/Krasjet)