Hands-On Kotlin Web Development with Ktor

Video description

Build web apps quickly and with less effort using Kotlin and Ktor

About This Video

  • Create a lightweight REST-enabled backend from scratch for use on your website or mobile app
  • Understand the Ktor lifecycle and how to apply plugins to develop a bookstore app and master core app development
  • Create a Ktor project from scratch and get started with Kotlin coroutines and Kotlin class extensions

In Detail

Ktor is a Kotlin-specific framework for building asynchronous client- and server-side web applications. It is one of the most widely-adopted and supported alternatives to Java for Android app development. Ktor has gained massive popularity remarkably quickly, and you'll rapidly create connected applications in Kotlin with minimal effort.

This course provides hands-on training in a practical and engaging way to get you started building an end-to-end web application using Kotlin's popular framework, Ktor. You will begin by swiftly covering Kotlin and Ktor basics (for this, you'll benefit from some basic knowledge of Kotlin before starting this course).

You'll cover setting up your project-which will be full-stack (client and server)—and create your web application in the Ktor framework using Kotlin as your language. You'll cover some important Ktor features and solutions, and will cover routing and HTML Builder. You'll also run your configured application and test it.

By the end of the course, you will have learned how to build web applications with Kotlin using the Ktor framework.

Publisher resources

Download Example Code

Table of contents

  1. Chapter 1 : Getting Started with Kotlin and Ktor
    1. The Course Overview 00:04:23
    2. What is a backend 00:02:40
    3. Why choose Ktor as backend? 00:01:55
    4. Creating our first project with IntelliJ plugin and ktor.start.io 00:05:44
    5. Creating our first route that returns a string 00:07:43
    6. Bookstore-application: Create and set up dependencies 00:03:39
  2. Chapter 2 : Understanding the Ktor Lifecycle
    1. Kotlin coroutine explained and demonstrated 00:08:30
    2. Kotlin Extension explained and demonstrated 00:06:49
    3. Ktor architecture and lifecycle explained 00:03:52
    4. Ktor installation and configuration of features 00:06:32
    5. Ktor routes in general 00:17:56
    6. Calling 3rd party REST services 00:11:55
    7. Endpoints for our book store. Get and post books 00:16:12
    8. The PUT,POST,GET and DELETE Routes 00:10:50
    9. Let Us Test the Endpoints with cURL 00:13:58
  3. Chapter 3 : Working with Ktor REST API
    1. Creating a REST API 00:18:50
    2. Feature Content Negotiation 00:06:28
    3. Conversion from Kotlin object to JSON with Jackson 00:07:14
    4. Auto-update web application on build 00:07:10
    5. Routes with path variables 00:05:20
    6. Routes with request parameters 00:03:48
    7. Getting and setting headers 00:05:32
    8. Bookstore-application: Convert json to objects. Add search endpoints with request parameters 00:07:51
  4. Chapter 4 : Ktor REST API - Error handling and authentication
    1. Feature Status Pages 00:09:20
    2. Data posted to the route endpoint 00:09:00
    3. Basic Authentication on chosen endpoints 00:09:31
    4. Routing interceptors - Check admin rights 00:07:17
    5. CallLogging log all incoming requests 00:02:57
    6. Metrics statistics on the usage of the endpoints 00:08:05
    7. Bookstore-application: Add error handling and basic authentication to our book store 00:06:06
  5. Chapter 5 : Persisting data with MongoDB
    1. Starting up a MongoDb with Docker-compose and adding the MongoDB dependency 00:09:41
    2. Insert data to a MongoDB 00:09:39
    3. Updating and deleting data 00:07:54
    4. Extracting data with a query 00:04:27
    5. Sorting and paging 00:06:32
    6. Bookstore-application: Saving, deleting and extracting books 00:04:16
  6. Chapter 6 : Testing the Ktor application
    1. Test strategy - No server context needed 00:06:26
    2. Setting up a Ktor test 00:07:19
    3. What is a good unit test 00:04:18
    4. Performance testing with K6 00:06:40
    5. Bookstore-application: Setup K6 and unit tests 00:03:16
  7. Chapter 7 : A web UI with Ktor - HTML and CSS DSL
    1. HTML DSL - Installing the feature and writing basic HTML 00:06:41
    2. HTML DSL importing css 00:09:18
    3. HTML DSL importing static files 00:05:17
    4. CSS DSL - Installing the feature and writing basic CSS 00:06:53
    5. CSS DSL rules 00:08:56
    6. HTML Templating and passing variables 00:10:17
    7. Bookstore-application: Create a login page 00:10:14
    8. Bookstore-application: Create a Book search page 00:07:38
    9. Bookstore-application: Create a Cart checkout page 00:14:12
    10. Bookstore-application: Create receipt page 00:05:42
  8. Chapter 8 : Prepare for deployment
    1. Create a .jar file With Gradle 00:07:39
    2. Docker multi-stage build - Build image 00:07:30
    3. Docker multi-stage build - Execution image 00:06:38
    4. Bookstore-application: Create a docker image and spin it up 00:08:54

Product information

  • Title: Hands-On Kotlin Web Development with Ktor
  • Author(s): Mike Møller Nielsen
  • Release date: June 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781838640767