ktor_使用Ktor构建服务器的体系结构建议

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)

Image for post
Suggested Ktor server's architecture
建议的Ktor服务器架构

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文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值