Monday, March 29, 2021

Part-3 Ktor Kotlin MySQL Integration tutorial - Best Practices Code

 Here you will learn how to integrate MYSQL with Ktor using Kotlin Need to create Database Screen-shots attached for reference.

Below is my Github URL:
https://github.com/Abhinaw/MySqlKtorTutorial




Get All Todos response coming from database:

http://localhost:8081/todos

[ { "id": 2, "title": "Test todo #2", "done": true }, { "id": 3, "title": "Record Video #6", "done": true }, { "id": 4, "title": "Todo Test #4", "done": true } ]

Part-2 Middle-Tier Implementation with #Ktor #kotlindeveloper

Working demo with best practices with proper handling GET, POST, PUT, DELETE operation. You can request JSON and get a response as JSON.

Below is the Github URL:

https://github.com/Abhinaw/KtorEnhancedTutorialRequestResponseDemo

Here you can see live request and response that you are making through the postman . you can perform add,delete,update in the code below is the working example that i performed:

GET:

http://localhost:8081/todos [ { "id": 2, "title": "Record Video", "done": true }, { "id": 3, "title": "Record Video #4", "done": true }, { "id": 4, "title": "Record Video", "done": true }, { "id": 5, "title": "Record Video", "done": true }, { "id": 6, "title": "Record Video", "done": true }, { "id": 7, "title": "Record Video", "done": true }, { "id": 8, "title": "Record Video", "done": true } ]

POST: http://localhost:8081/todos request: { "title": "Record Video", "done": true } response: { "id": 8, "title": "Record Video", "done": true }

PUT: http://localhost:8081/todos/3

request: { "title": "Record Video #4", "done": true }

response: 200OK

DELETE:

http://localhost:8081/todos/1

request: { "title": "Record Video", "done": true } response: 200OK



Part-1 Building Middle-Tier in Kotlin Using Ktor #kotlin #Ktor

 Very Simple Working Code Example. Below is my GitHub URL

https://github.com/Abhinaw/Kotlin_Ktor_Demo_App

Many web applications and services are built using the Spring Framework. While Spring is incredibly powerful and Kotlin is useful nobody can accuse it of being lightweight because of the benefits it has such as support of immutable data and null detection, as well as having less of the bloat of Java. Bring these two together, a lightweight HTTP framework and a nice programming language and you get Ktor. It is heavily based on Kotlin coroutines and so supports a high degree of asynchrony. I have tried to write as much as possible easy code for all so that everyone can understand it.