- A very basic zio-http / zio-quill example
- Demonstrates how to use a Db ZLayer implementing data access using zio-quill with zio-http
- The example doesn't go deep into DB specific details (surrogate ids, constraints etc.)
- zio version "1.0.13"
- zio-quill versin "3.8.0"
- h2 version "1.4.199"
- zio-http version "1.0.0.0-RC19"
- ZHttpQuillMain
- Shows how to set up a server and zio-http endpoints
- Just run via IDE or sbt console
- PersonDb
- Shows how to set up a ZIO Service layer
- It can be dependency injected and used like shown in the Main.
- application.conf for H2DB setup
- h2-schema.sql
Describe end points for
- adding dynamic user to H2DB. POST http://localhost:8090/person
- getting user(s) from H2DB. GET http://localhost:8090/user/generateduuid
- The sample application is built in the form of assembly and executed with run script
sbt clean assembly
./run_zhttp_quill.sh
- The server can be stopped running kill script
./kill_zhttp_quill.sh
- The output is generated in the app.log
tail app.log
Inject dynamic UUID data by firing this POST endpoint 2 or more times (injecting new records)
curl -X POST http://localhost:8090/person
Persons: List(Person(102,f7743392-68d2-4acc-b941-c870c0571134,27))%
curl -X POST http://localhost:8090/person
Persons: List(Person(102,f7743392-68d2-4acc-b941-c870c0571134,27), Person(102,fb594b9a-4e34-4a04-b013-2d9ad1fa47cf,27))
Get specific user by name
curl http://localhost:8090/user/f7743392-68d2-4acc-b941-c870c0571134
Hello: List(Person(102,f7743392-68d2-4acc-b941-c870c0571134,27))