-
Notifications
You must be signed in to change notification settings - Fork 346
KTOR-8962 Update the Create a new Ktor project tutorial #708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b6bd244
KTOR-8962 Update the Create a new Ktor project tutorial
vnikolova 09ef830
fix wrong library name
vnikolova 0fc7ee9
update code snippets
vnikolova 32d8029
update the example explanation in maven-assembly-plugin.md
vnikolova 69faa5c
KTOR-9002 update maven dependency and add a warning for YAML support
vnikolova c3df5e1
resolve comments
vnikolova bc8252a
fix typos
vnikolova a310462
fix even more typos
vnikolova 3dd48c6
resolve comments
vnikolova b191c56
update screenshots and fix casing
vnikolova eb0b645
fix final step in second additional task
vnikolova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
codeSnippets/snippets/tutorial-server-get-started-maven/src/main/kotlin/Application.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example | ||
|
|
||
| import io.ktor.server.application.* | ||
|
|
||
| fun main(args: Array<String>) { | ||
| io.ktor.server.netty.EngineMain.main(args) | ||
| } | ||
|
|
||
| fun Application.module() { | ||
| configureRouting() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
...ets/snippets/tutorial-server-get-started-maven/src/main/kotlin/com/example/Application.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...snippets/tutorial-server-get-started-maven/src/main/kotlin/com/example/plugins/Routing.kt
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
codeSnippets/snippets/tutorial-server-get-started-maven/src/test/kotlin/ApplicationTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.example | ||
|
|
||
| import io.ktor.client.request.get | ||
| import io.ktor.client.statement.bodyAsText | ||
| import io.ktor.http.HttpStatusCode | ||
| import io.ktor.http.contentType | ||
| import io.ktor.server.testing.testApplication | ||
| import kotlin.test.Test | ||
| import kotlin.test.assertContains | ||
| import kotlin.test.assertEquals | ||
|
|
||
| class ApplicationTest { | ||
|
|
||
| @Test | ||
| fun testRoot() = testApplication { | ||
| application { | ||
| module() | ||
| } | ||
| val response = client.get("/") | ||
|
|
||
| assertEquals(HttpStatusCode.OK, response.status) | ||
| assertEquals("Hello World!", response.bodyAsText()) | ||
| } | ||
|
|
||
| @Test | ||
| fun testNewEndpoint() = testApplication { | ||
| application { | ||
| module() | ||
| } | ||
|
|
||
| val response = client.get("/test1") | ||
|
|
||
| assertEquals(HttpStatusCode.OK, response.status) | ||
| assertEquals("html", response.contentType()?.contentSubtype) | ||
| assertContains(response.bodyAsText(), "Hello From Ktor") | ||
| } | ||
| } |
21 changes: 0 additions & 21 deletions
21
...snippets/tutorial-server-get-started-maven/src/test/kotlin/com/example/ApplicationTest.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,15 @@ | ||
| # Getting started with a Ktor Server | ||
|
|
||
| A sample project created in | ||
| A sample standalone project created in | ||
| the [Create, open and run a new Ktor project](https://ktor.io/docs/server-create-a-new-project.html) | ||
| tutorial. | ||
|
|
||
| > This sample is part of the [codeSnippets](../../README.md) Gradle project. | ||
|
|
||
| ## Run | ||
|
|
||
| To run the sample, execute the following command in a repository's root directory: | ||
| To run the sample, execute the following command in the project's root directory: | ||
|
|
||
| ```bash | ||
| ./gradlew :tutorial-server-get-started:run | ||
| ./gradlew run | ||
| ``` | ||
|
|
||
| Navigate to [http://0.0.0.0:8080/](http://0.0.0.0:8080/) to see the output. |
37 changes: 16 additions & 21 deletions
37
codeSnippets/snippets/tutorial-server-get-started/build.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,23 @@ | ||
| val ktor_version: String by project | ||
| val kotlin_version: String by project | ||
| val logback_version: String by project | ||
|
|
||
| plugins { | ||
| application | ||
| kotlin("jvm") | ||
| id("io.ktor.plugin") version "3.3.1" | ||
| alias(libs.plugins.kotlin.jvm) | ||
| alias(libs.plugins.ktor) | ||
| } | ||
|
|
||
| application { | ||
| mainClass.set("io.ktor.server.netty.EngineMain") | ||
| } | ||
| group = "com.example" | ||
| version = "0.0.1" | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| maven { url = uri("https://maven.pkg.jetbrains.space/public/p/ktor/eap") } | ||
| application { | ||
| mainClass = "io.ktor.server.netty.EngineMain" | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation("io.ktor:ktor-server-status-pages:$ktor_version") | ||
| implementation("io.ktor:ktor-server-core-jvm") | ||
| implementation("io.ktor:ktor-server-netty-jvm") | ||
| implementation("ch.qos.logback:logback-classic:$logback_version") | ||
| implementation("io.ktor:ktor-server-config-yaml:$ktor_version") | ||
| testImplementation("io.ktor:ktor-server-test-host-jvm:$ktor_version") | ||
| testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") | ||
| } | ||
| // Added new dependency | ||
| implementation(libs.ktor.server.status.pages) | ||
| // Existing dependencies | ||
| implementation(libs.ktor.server.core) | ||
| implementation(libs.ktor.server.netty) | ||
| implementation(libs.logback.classic) | ||
| implementation(libs.ktor.server.config.yFaml) | ||
| testImplementation(libs.ktor.server.test.host) | ||
| testImplementation(libs.kotlin.test.junit) | ||
| } | ||
1 change: 1 addition & 0 deletions
1
codeSnippets/snippets/tutorial-server-get-started/gradle.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| kotlin.code.style=official |
17 changes: 17 additions & 0 deletions
17
codeSnippets/snippets/tutorial-server-get-started/gradle/libs.versions.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [versions] | ||
| kotlin = "2.2.20" | ||
| ktor = "3.3.0" | ||
| logback = "1.4.14" | ||
|
|
||
| [libraries] | ||
| ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" } | ||
| ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" } | ||
| ktor-server-status-pages = { module = "io.ktor:ktor-server-status-pages", version.ref = "ktor" } | ||
| logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } | ||
| ktor-server-config-yaml = { module = "io.ktor:ktor-server-config-yaml", version.ref = "ktor" } | ||
| ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" } | ||
| kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } | ||
|
|
||
| [plugins] | ||
| kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } | ||
| ktor = { id = "io.ktor.plugin", version.ref = "ktor" } |
Binary file added
BIN
+42.7 KB
codeSnippets/snippets/tutorial-server-get-started/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
codeSnippets/snippets/tutorial-server-get-started/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip | ||
| networkTimeout=10000 | ||
| validateDistributionUrl=true | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.