https://github.com/thma/servant-gp
writing a Rest Service with a generic-persistence backend
https://github.com/thma/servant-gp
Last synced: about 1 year ago
JSON representation
writing a Rest Service with a generic-persistence backend
- Host: GitHub
- URL: https://github.com/thma/servant-gp
- Owner: thma
- License: other
- Created: 2023-03-02T15:04:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T17:43:14.000Z (over 2 years ago)
- Last Synced: 2025-04-04T06:23:21.179Z (over 1 year ago)
- Language: Haskell
- Size: 57.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# servant-gp
This is a demo project for [servant](https://haskell-servant.github.io/) and [generic-persistence](https://github.com/thma/generic-persistence).
It shows how to use servant to build a REST API for a simple persistence model.
The Data is stored in a Sqlite database using generic-persistence as persistence layer.
The model is defined in `src/Models.hs` and the API is defined in `src/UserApi.hs`.
The API is implemented in `src/UserServer.hs` (with the GP default API) and in `src/UserServerSafe.hs` (using an API with total functions, where exceptions are returned as `Left PersistenceException`).
The `app/Main.hs` module contains the main function to start the server.
`src/SwaggerEntityService` contains a servant-swagger module to generate a swagger API description.
```bash
ormolu -i ./**/*.hs
stylish-haskell -i ./**/*.hs
``````