{"id":342645,"date":"2022-12-14T17:31:30","date_gmt":"2022-12-14T17:31:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=342645"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=342645","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Ktor. \u0427\u0430\u0441\u0442\u044c 1<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/github.com\/Egor-Liadsky\/-ktor-get-started-sample\" rel=\"noopener noreferrer nofollow\">\u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/a><\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Ktor?<\/h2>\n<p><strong>Ktor<\/strong> \u2014 \u044d\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 Kotlin.<\/p>\n<h2>\u041f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a:<\/p>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 Intellij IDEA.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043f\u043b\u0430\u0433\u0438\u043d Ktor \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c).<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 Ktor, \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 Intellij IDEA \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: <\/p>\n<ol>\n<li>\n<p>\u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0449\u0435\u043b\u043a\u043d\u0438\u0442\u0435 <strong>New Project.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 <strong>\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c<\/strong> \u0438\u0437 \u043b\u0435\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 <strong>Ktor<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:  .<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0f7\/6c6\/dc9\/0f76c6dc914a1172bc3b2cfb7cc9ca2b.png\" width=\"1604\" height=\"1224\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0f7\/6c6\/dc9\/0f76c6dc914a1172bc3b2cfb7cc9ca2b.png\"\/><figcaption><\/figcaption><\/figure>\n<ul>\n<li>\n<p><strong>Name<\/strong>: \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Location<\/strong>: \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Build system<\/strong>: \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Website<\/strong>: \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0434\u043e\u043c\u0435\u043d, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u0430\u043a\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Artifact<\/strong>: \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0438\u043c\u044f \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u0430.  <\/p>\n<\/li>\n<li>\n<p><strong>Ktor version<\/strong>: \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Ktor.  <\/p>\n<\/li>\n<li>\n<p><strong>Engine<\/strong>: \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0432\u0438\u0436\u043e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Configuration<\/strong> <strong>in<\/strong>: \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043a\u043e\u0434\u0435 \u0438\u043b\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 HOCON.<\/p>\n<\/li>\n<li>\n<p><strong>Add sample code<\/strong>: \u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u0435\u0446 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435.   <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.\u00a0\u041d\u0430\u0436\u043c\u0438\u0442\u0435\u00a0<strong>Next<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.   <\/p>\n<\/li>\n<\/ul>\n<p>4. \u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u00a0\u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432\u00a0\u2014 \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u043e\u0431\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Ktor, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0441\u0436\u0430\u0442\u0438\u0435, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 cookie \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/821\/e0a\/538\/821e0a5381ad763c1584e8d3a2e88c4d.png\" width=\"1604\" height=\"1244\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/821\/e0a\/538\/821e0a5381ad763c1584e8d3a2e88c4d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u043f\u043e\u043a\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u00a0<strong>Routing<\/strong>\u00a0\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0\u041d\u0430\u0447\u043d\u0438\u0442\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u044c\u00a0<em>routing <\/em>\u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u043b\u0435\u0432\u043e\u043c \u043f\u043e\u043b\u0435 \u043f\u043e\u0438\u0441\u043a\u0430, \u043d\u0430\u0439\u0434\u0438\u0442\u0435\u00a0<strong>Routing <\/strong>\u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435\u00a0<strong>Add<\/strong>.  <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c5\/c01\/271\/9c5c01271142afa99e33716870e2e2ee.gif\" width=\"1393\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c5\/c01\/271\/9c5c01271142afa99e33716870e2e2ee.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 <strong>Create<\/strong> \u0438 \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 IntelliJ IDEA \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Ktor<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Ktor, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:  <\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432\u0438\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <strong>Project <\/strong>\u0438 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u00a0<strong>Application.kt<\/strong>\u00a0, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0443\u0442\u0438:  <code>src\u00a0\/main\u00a0\/kotlin\u00a0\/com\u00a0\/example\/\u00a0Application.kt<\/code>  <\/p>\n<\/li>\n<\/ol>\n<ol start=\"2\">\n<li>\n<p>\u0412 \u0444\u0430\u0439\u043b <strong>Application.kt <\/strong>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434<strong>:<\/strong><\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">package com.example  import io.ktor.server.engine.* import io.ktor.server.netty.* import com.example.plugins.*  fun main() {     embeddedServer(Netty, port = 8080, host = \"0.0.0.0\") {         configureRouting()     }.start(wait = true) }<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430:  <\/p>\n<ul>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>embeddedServer<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043a\u043e\u0434\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>configureRouting<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439\u00a0<a href=\"https:\/\/ktor.io\/docs\/routing-in-ktor.html\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e<\/a>\u00a0.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u200b\u200b\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u00a0\u043f\u0430\u043a\u0435\u0442\u043f\u0435 <code>plugins<\/code> (\u0444\u0430\u0439\u043b\u00a0<strong>Routing.kt<\/strong>\u00a0).  <\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">package com.example.plugins  import io.ktor.server.routing.* import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.request.*  fun Application.configureRouting() {      routing {         get(\"\/\") {             call.respondText(\"Hello World!\")         }     } }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>get<\/code>\u0432\u043d\u0443\u0442\u0440\u0438\u00a0<code>routing<\/code>\u0431\u043b\u043e\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b GET, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043f\u0443\u0442\u0438\u00a0\/\u00a0, \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043e\u0442\u0432\u0435\u0442\u043e\u043c.  <\/p>\n<ol start=\"3\">\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0449\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u0440\u044f\u0434\u043e\u043c \u0441\u00a0<code>main<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435\u00a0<strong>run ApplicationKt<\/strong>\u00a0.  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ff0\/32d\/da3\/ff032dda38ace6bb940d0053fe5ecb9c.png\" width=\"1412\" height=\"656\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ff0\/32d\/da3\/ff032dda38ace6bb940d0053fe5ecb9c.png\"\/><figcaption><\/figcaption><\/figure>\n<ol start=\"4\">\n<li>\n<p>\u041f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 Intellij IDEA \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.\u00a0\u0412 \u043e\u043a\u043d\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <strong>Run<\/strong> \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:  <\/p>\n<p><code>[main] INFO  ktor.application - Responding at http:\/\/0.0.0.0:8080<\/code> <\/p>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u043e\u0442\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443\u00a0<strong>http:\/\/0.0.0.0:8080<\/strong>\u00a0.\u00a0\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0449\u0435\u043b\u043a\u043d\u0443\u0442\u044c \u044d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bb1\/cae\/1ff\/bb1cae1ff41c62235d0a2b50740206c8.png\" width=\"860\" height=\"400\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bb1\/cae\/1ff\/bb1cae1ff41c62235d0a2b50740206c8.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Ktor<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:  <\/p>\n<ol>\n<li>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u00a0<strong>ApplicationTest.kt<\/strong>\u00a0, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0443\u0442\u0438:\u00a0<strong>src\u00a0\/test\u00a0\/kotlin\u00a0\/com\u00a0\/example\/\u00a0ApplicationTest.kt<\/strong>\u00a0.\u00a0\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>testApplication<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GET \u043a\u00a0<strong>\/<\/strong>\u00a0\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442, \u0449\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u0440\u044f\u0434\u043e\u043c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439\u00a0<code>testRoot<\/code> \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>run ApplicationTest.test<\/strong>\u00a0.  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b52\/237\/486\/b52237486ba80cb812b5cab5f5addd79.png\" width=\"1412\" height=\"840\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b52\/237\/486\/b52237486ba80cb812b5cab5f5addd79.png\"\/><figcaption><\/figcaption><\/figure>\n<ol start=\"3\">\n<li>\n<p>\u041f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 IntelliJ IDEA \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0442\u0435\u0441\u0442 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u043e\u043a\u043d\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <strong>Run<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/522\/d6c\/952\/522d6c95267766bfc712d6f86dfc02d3.png\" width=\"1412\" height=\"542\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/522\/d6c\/952\/522d6c95267766bfc712d6f86dfc02d3.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0449\u0451 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/705480\/\"> https:\/\/habr.com\/ru\/post\/705480\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/github.com\/Egor-Liadsky\/-ktor-get-started-sample\" rel=\"noopener noreferrer nofollow\">\u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/a><\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Ktor?<\/h2>\n<p><strong>Ktor<\/strong> \u2014 \u044d\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 Kotlin.<\/p>\n<h2>\u041f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u043a:<\/p>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 Intellij IDEA.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043f\u043b\u0430\u0433\u0438\u043d Ktor \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c).<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 Ktor, \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 Intellij IDEA \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: <\/p>\n<ol>\n<li>\n<p>\u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0449\u0435\u043b\u043a\u043d\u0438\u0442\u0435 <strong>New Project.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 <strong>\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c<\/strong> \u0438\u0437 \u043b\u0435\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 <strong>Ktor<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:  .<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<ul>\n<li>\n<p><strong>Name<\/strong>: \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Location<\/strong>: \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Build system<\/strong>: \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Website<\/strong>: \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0434\u043e\u043c\u0435\u043d, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u0430\u043a\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Artifact<\/strong>: \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0438\u043c\u044f \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u0430.  <\/p>\n<\/li>\n<li>\n<p><strong>Ktor version<\/strong>: \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Ktor.  <\/p>\n<\/li>\n<li>\n<p><strong>Engine<\/strong>: \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0432\u0438\u0436\u043e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Configuration<\/strong> <strong>in<\/strong>: \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043b\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043a\u043e\u0434\u0435 \u0438\u043b\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 HOCON.<\/p>\n<\/li>\n<li>\n<p><strong>Add sample code<\/strong>: \u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u0435\u0446 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435.   <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.\u00a0\u041d\u0430\u0436\u043c\u0438\u0442\u0435\u00a0<strong>Next<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.   <\/p>\n<\/li>\n<\/ul>\n<p>4. \u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u00a0\u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432\u00a0\u2014 \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u043e\u0431\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Ktor, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0441\u0436\u0430\u0442\u0438\u0435, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 cookie \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u043f\u043e\u043a\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u00a0<strong>Routing<\/strong>\u00a0\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0\u041d\u0430\u0447\u043d\u0438\u0442\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u044c\u00a0<em>routing <\/em>\u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u043b\u0435\u0432\u043e\u043c \u043f\u043e\u043b\u0435 \u043f\u043e\u0438\u0441\u043a\u0430, \u043d\u0430\u0439\u0434\u0438\u0442\u0435\u00a0<strong>Routing <\/strong>\u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435\u00a0<strong>Add<\/strong>.  <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 <strong>Create<\/strong> \u0438 \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 IntelliJ IDEA \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Ktor<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Ktor, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:  <\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432\u0438\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <strong>Project <\/strong>\u0438 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u00a0<strong>Application.kt<\/strong>\u00a0, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0443\u0442\u0438:  <code>src\u00a0\/main\u00a0\/kotlin\u00a0\/com\u00a0\/example\/\u00a0Application.kt<\/code>  <\/p>\n<\/li>\n<\/ol>\n<ol start=\"2\">\n<li>\n<p>\u0412 \u0444\u0430\u0439\u043b <strong>Application.kt <\/strong>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434<strong>:<\/strong><\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">package com.example  import io.ktor.server.engine.* import io.ktor.server.netty.* import com.example.plugins.*  fun main() {     embeddedServer(Netty, port = 8080, host = \"0.0.0.0\") {         configureRouting()     }.start(wait = true) }<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430:  <\/p>\n<ul>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>embeddedServer<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043a\u043e\u0434\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>configureRouting<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439\u00a0<a href=\"https:\/\/ktor.io\/docs\/routing-in-ktor.html\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e<\/a>\u00a0.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u200b\u200b\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u00a0\u043f\u0430\u043a\u0435\u0442\u043f\u0435 <code>plugins<\/code> (\u0444\u0430\u0439\u043b\u00a0<strong>Routing.kt<\/strong>\u00a0).  <\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"kotlin\">package com.example.plugins  import io.ktor.server.routing.* import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.request.*  fun Application.configureRouting() {      routing {         get(\"\/\") {             call.respondText(\"Hello World!\")         }     } }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>get<\/code>\u0432\u043d\u0443\u0442\u0440\u0438\u00a0<code>routing<\/code>\u0431\u043b\u043e\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b GET, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043f\u0443\u0442\u0438\u00a0\/\u00a0, \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043e\u0442\u0432\u0435\u0442\u043e\u043c.  <\/p>\n<ol start=\"3\">\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0449\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u0440\u044f\u0434\u043e\u043c \u0441\u00a0<code>main<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435\u00a0<strong>run ApplicationKt<\/strong>\u00a0.  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<ol start=\"4\">\n<li>\n<p>\u041f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 Intellij IDEA \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.\u00a0\u0412 \u043e\u043a\u043d\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <strong>Run<\/strong> \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:  <\/p>\n<p><code>[main] INFO  ktor.application - Responding at http:\/\/0.0.0.0:8080<\/code> <\/p>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u043e\u0442\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443\u00a0<strong>http:\/\/0.0.0.0:8080<\/strong>\u00a0.\u00a0\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0449\u0435\u043b\u043a\u043d\u0443\u0442\u044c \u044d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Ktor<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:  <\/p>\n<ol>\n<li>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u00a0<strong>ApplicationTest.kt<\/strong>\u00a0, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0443\u0442\u0438:\u00a0<strong>src\u00a0\/test\u00a0\/kotlin\u00a0\/com\u00a0\/example\/\u00a0ApplicationTest.kt<\/strong>\u00a0.\u00a0\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>testApplication<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GET \u043a\u00a0<strong>\/<\/strong>\u00a0\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442, \u0449\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u0440\u044f\u0434\u043e\u043c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439\u00a0<code>testRoot<\/code> \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>run ApplicationTest.test<\/strong>\u00a0.  <\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<ol start=\"3\">\n<li>\n<p>\u041f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u043f\u043e\u043a\u0430 IntelliJ IDEA \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0442\u0435\u0441\u0442 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u043e\u043a\u043d\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <strong>Run<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0449\u0451 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/705480\/\"> https:\/\/habr.com\/ru\/post\/705480\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-342645","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=342645"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342645\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=342645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=342645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=342645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}