ktor
After attending KotlinConf 2018 and inspired by Ryan Harter talk there (check it here), I've started working with Ktor to develop a backend to connect my apps. I have to say I'm really impressed how easy it was to develop a REST API, including JWT authentication, database connection and Docker deployment with Docker Compose.
在参加KotlinConf 2018并受到Ryan Harter的演讲启发( 在此处查看 )之后,我开始与Ktor合作开发后端以连接我的应用程序。 我必须说,我真的给开发REST API这么容易感到印象深刻,包括使用Docker Compose进行JWT身份验证,数据库连接和Docker部署。
Before we start, I would like to warn everyone about the aim of this article. There are several publications about how to code using Ktor, and the official documentation and community behind it are amazing, so I won't spend too much time explaining about how to get things done. This article will be focused on the next step, when you have something working but you want a clean and testable code. This is the architecture I'm using in a real life & production environment server to provide a REST API to my app MySecretSanta.
在开始之前,我想提醒大家本文的目的。 关于如何使用Ktor进行编码的出版物很多,其背后的官方文档和社区也很棒,因此我不会花太多时间来解释如何完成工作。 当您可以进行某些工作但想要一个干净且可测试的代码时,本文将重点关注下一步。 这是我在现实生活和生产环境服务器中使用的体系结构,用于为我的应用程序MySecretSanta提供REST API。
架构图 (Architecture diagram)
At the time of writing this article, Ktor server can only be run in JVM, so we will start with a Java main function placed in Application.kt file.
在撰写本文时,Ktor服务器只能在JVM中运行,因此我们将从放置在Application.kt文件