Simple application to showcase a CRUD Rest API application in Kotlin
- JDK 21
- Kotlin
- Gradle
- Docker
- Ktor
- Postgres
- Curl
Make sure you have the Java JDK 21 installed You can check which version you have installed using this command:
java -version
Make sure you have docker installed using this command:
docker --version
Make sure you have curl installed using this command:
curl --version
Build the code without running it
./gradlew jar
Run all the tests
./gradlew test
Creating a docker image should be as simple as
docker build -t kotlinktorapp .
docker compose up
Request to get the all the users:
curl --location --request GET 'http://localhost:8080/users'
Example of a response:
[ { "id": 1, "name": "aaa", "email": "aaa@mail" }, { "id": 2, "name": "bbb", "email": "bbb@mail" } ]
Request to create a new user
curl --location --request POST 'http://localhost:8080/user' \
--header 'Content-Type: application/json' \
--data-raw '{"name": "aaa","email": "aaa@mail"}'
Request to get one specific user:
curl --location --request GET 'http://localhost:8080/user/2'
Example of a response:
{ "id": 1, "name": "new", "email": "new@mail" }
Request to update a user
curl --location --request PUT 'http://localhost:8080/user/2' \
--header 'Content-Type: application/json' \
--data-raw '{"id":2,"name": "new","email": "new@mail"}'
Request to delete a user
curl --location --request DELETE 'http://localhost:8080/user/3'
Find the newest version of gradle here: https://gradle.org/releases/ Then run this command: (Remeber to repealce $gradleVersjon with the newest version)
./gradlew wrapper --gradle-version $gradleVersjon
Want to add a feature? see CONTRIBUTING
This project is maintained by CODEOWNERS
Questions? please create an issue