https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ktor
  • k

    kasper.kondzielski

    11/21/2018, 8:49 PM
    here is my code:
    val client = HttpClient()
        install(ContentNegotiation) {
            jackson {
                enable(SerializationFeature.INDENT_OUTPUT)
            }
        }
    
        runBlocking {
            val buildLog = client.get<HttpResponse>("<https://jitpack.io/com/github/ghostbuster91/gh-webhook-test/f82f1363432678ab9bf4bab325b7af3a78460d35/>")
            println("start")
            println(buildLog.readText())
        }
    and after invoking it
    buildLog.readText
    is empty
    e
    7 replies · 2 participants
  • a

    aridder

    11/21/2018, 9:03 PM
    Hi! I've started looking into Ktor and it seems great. But I struggle with the Autoreload settings. When running the application i get message:
    No ktor.deployment.watch patterns match classpath entries, automatic reload is not active
    I use OpenJDK 1.8 This works, but not watching the directories i want:
    watchPaths = listOf("bystativ-server-gradle/")
    It only watches the bystativ-server-gradle/out directory and its subfolders. I want it to watch the bystativ-server-gradle/src directory
    s
    c
    2 replies · 3 participants
  • k

    kodal

    11/22/2018, 2:42 PM
    Hello, autoreload works fine, but after that server not responding. [TRACE Application - Unhandled: GET - /]
    o
    c
    +1
    5 replies · 4 participants
  • b

    Bernhard

    11/22/2018, 8:02 PM
    why choose ktor when there's spring boot
    h
    n
    +3
    19 replies · 6 participants
  • j

    jvassbo

    11/23/2018, 12:37 PM
    Are there any contribution guidelines for Ktor?
    e
    3 replies · 2 participants
  • t

    tipsy

    11/24/2018, 12:02 PM
    does ktor have reverse routing for the dsl?
    o
    y
    12 replies · 3 participants
  • v

    v

    11/25/2018, 2:28 PM
    Gradle build failing
    repositories {
        jcenter()
        mavenCentral()
    }
    
    dependencies {
       ...
        compile "io.ktor:ktor-client-json:$ktor_version"
        compile "io.ktor:ktor-client-gson:$ktor_version"
    }
    > Could not resolve all files for configuration ':compileClasspath'.
       > Could not find org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.9.0.
         Searched in the following locations:
           - <https://jcenter.bintray.com/org/jetbrains/kotlinx/kotlinx-serialization-runtime-common/0.9.0/kotlinx-serialization-runtime-common-0.9.0.pom>
           - <https://jcenter.bintray.com/org/jetbrains/kotlinx/kotlinx-serialization-runtime-common/0.9.0/kotlinx-serialization-runtime-common-0.9.0.jar>
           - <https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-serialization-runtime-common/0.9.0/kotlinx-serialization-runtime-common-0.9.0.pom>
           - <https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-serialization-runtime-common/0.9.0/kotlinx-serialization-runtime-common-0.9.0.jar>
         Required by:
             project : > io.ktor:ktor-client-json:1.0.0
       > Could not find org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.9.0.
         Searched in the following locations:
           - <https://jcenter.bintray.com/org/jetbrains/kotlinx/kotlinx-serialization-runtime/0.9.0/kotlinx-serialization-runtime-0.9.0.pom>
           - <https://jcenter.bintray.com/org/jetbrains/kotlinx/kotlinx-serialization-runtime/0.9.0/kotlinx-serialization-runtime-0.9.0.jar>
           - <https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-serialization-runtime/0.9.0/kotlinx-serialization-runtime-0.9.0.pom>
           - <https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-serialization-runtime/0.9.0/kotlinx-serialization-runtime-0.9.0.jar>
         Required by:
             project : > io.ktor:ktor-client-gson:1.0.0 > io.ktor:ktor-client-json-jvm:1.0.0
    😢 1
    t
    1 reply · 2 participants
  • v

    v

    11/25/2018, 8:28 PM
    Now it works from Gradle, but running the same thing from IntelliJ gives
    /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/bin/java ...
    Error occurred during initialization of boot layer
    java.lang.module.ResolutionException: Modules ktor.server.core and ktor.utils.jvm export package io.ktor.util to module io.netty.codec.http2
    e
    s
    12 replies · 3 participants
  • s

    Sergey Shnifer

    11/26/2018, 2:11 PM
    Hello there! I installed ktor plugin, started my first hello world ktor server and it works fine if I run it from IDE. Then I build a jar, but got "no main manifest attribute in hello.jar" when try to run it.
    l
    g
    +1
    5 replies · 4 participants
  • r

    Riccardo Montagnin

    11/26/2018, 2:19 PM
    Hello, how can I add an interceptor so that each authenticated request returns the user a new token inside a custom header?
    m
    2 replies · 2 participants
  • m

    mp

    11/26/2018, 3:54 PM
    netty is a low level networking lib, which ktor can use (or not -- up to you to choose the underlying engine). vertx is another take on async network programming, similar in spirit to ktor. If you had to pick only one primary difference, it would be that ktor embraces coroutines as a way to make nonblocking i/o more programmer friendly, whereas vertx is more "traditional" -- vertx long predates kotlin's coroutines.
    d
    1 reply · 2 participants
  • h

    Hamza

    11/27/2018, 9:31 AM
    Anyone know how to get static files working with ktor? The sample seems a bit outdated (albeit still doesn’t work for me).
    static("public") {
        staticRootFolder = File(Server::class.java.classLoader.getResource("static").file)
        resources("styles")
        resources("js")
    }
    while my css file is in resources/static/styles/master.css, when i go to
    localhost:7000/public/styles/master.css
    i receive a 404
    s
    g
    5 replies · 3 participants
  • g

    gaetan

    11/27/2018, 2:13 PM
    What is the correct way of handling the CacheOptions creation? I don’t understand the interest of this construction: a constructor and a factory function that share common signatures.
    c
    1 reply · 2 participants
  • m

    mp

    11/27/2018, 4:54 PM
    You might not be able to avoid them (e.g. integration with a third party product that requires them) but keep in mind that JWT & friends have an unreasonably high risk of shooting yourself in the foot
    s
    d
    34 replies · 3 participants
  • g

    gabin

    11/27/2018, 6:39 PM
    Also using android http client: implementation “io.ktor:ktor-client-android:$ktor_version” doesn’t cause the crash and works OK. Only “io.ktor:ktor-client-cio” crashes
    e
    2 replies · 2 participants
  • r

    rharter

    11/27/2018, 8:41 PM
    Is there a recommended way to to authorization with oauth, not just authentication? I've got a web app for which users must authenticate using oauth, but I also want to make sure their user account is flagged as an admin.
    r
    10 replies · 2 participants
  • e

    Eduard Boloș

    11/27/2018, 10:47 PM
    Hi! Something shady is going on while trying to use Static Content. This is my code:
    static("assets") {
        staticRootFolder = File("public")
        files("static")
    }
    The problem is that files are not resolved correctly. For instance, when I call /assets/static/file.txt on the server, I can see while debugging that in
    StaticContent.kt#L86
    , the file is resolved to
    public/static/static/file.txt
    instead of
    public/static/file.txt
    as I would expect. Pretty much the folder name is duplicated. Any idea what might be wrong, or wether this could be a bug in Ktor?
    1 reply · 1 participant
  • a

    Alice

    11/28/2018, 4:34 AM
    Hey guys, I'm trying to write a test w/ junit and handleRequest to test my login endpoint. If I use postman or curl or etc to make the request, it works just fine, but with my test function every one of my debug prints is null and prints inside the route don't go off. Here's my test code
    @Test
        fun `can register user and get jwt`() = withApplication {
            main()
            val newUser = NewUser("someusername", "someemail", "Tr0ub4dor83")
            val req = handleRequest(<http://HttpMethod.Post|HttpMethod.Post>, "/api/users/register") {
                setBody(
                    Gson().toJson(newUser)
                )
            }
            println(req.response.status().toString())
            println(req.response.headers)
            println(req.response.content)
            val token = req.response.headers["Authorization"]
            println(token)
        }
    am I doing something wrong without realizing?
    r
    18 replies · 2 participants
  • g

    gaetan

    11/28/2018, 12:59 PM
    The problem is more weird than I thought. This is the launching code:
    fun main(args: Array<String>) {
        embeddedServer(
            factory = Netty,
            port = 8080
        ) {
            proxyAndCache()
            mainModule()
        }.start(wait = true)
    }
    When I launch this code from my Idea Kotlin run configuration, the
    proxyAndCache
    function is called . But when I launch the code from gradle the function is not called.
    s
    1 reply · 2 participants
  • g

    gaetan

    11/28/2018, 1:03 PM
    Conclusion: don’t use a
    main
    to launch ktor.
    d
    1 reply · 2 participants
  • c

    ctierney

    11/28/2018, 8:24 PM
    But it doesn’t work if the
    withTestApplication
    block is at a higher level. It would be nice to be able to create the TestEngine once (e.g. at the
    given("an application")
    level) and use it in multiple
    on
    /
    it
    contexts.
    o
    d
    8 replies · 3 participants
  • g

    gotoOla

    11/29/2018, 1:11 PM
    this would process them in parallel, if you want to get the value you would go firstSite.await(), e.g.
    // Type of job here is Deffered<String>
    val job = async {
      "kanelbulle"
    }
    // The await will give you the value
    println(job.await())
    the await is “blocking” in terms of how your code is sequentially running but it doesn’t actually block threads as the await is a suspension point
    m
    2 replies · 2 participants
  • o

    orangy

    11/30/2018, 6:07 AM
    Please check https://ktor.io/quickstart/index.html
    t
    1 reply · 2 participants
  • i

    irus

    11/30/2018, 1:30 PM
    Is it really necessary to have compile dependency on
    kotlinx-serialization
    in
    ktor-client-jackson
    ?
    1 reply · 1 participant
  • t

    toomanyeduardos

    11/30/2018, 10:27 PM
    does anyone have an example of how to call Ktor from the commonMain? everything i find is for kotlin android, or js
    e
    2 replies · 2 participants
  • p

    pabl0rg

    12/01/2018, 3:38 AM
    Does anyone know if the kotlin blog runs on ktor? It seems to have stability issues on a fairly regular basis
    t
    o
    +1
    3 replies · 4 participants
  • s

    Soundlicious

    12/01/2018, 1:53 PM
    Why does intellij ask for the AndroidSdk while i'm trying to create a server with Ktor?? I'm confuse
    😕 1
    1 reply · 1 participant
  • a

    Alice

    12/02/2018, 2:38 AM
    Figured it out
    s
    7 replies · 2 participants
  • j

    jkbbwr

    12/02/2018, 5:02 AM
    When using kotlinx serialization with ktor client and websockets I get
    Caused by: kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class io.ktor.client.features.websocket.ClientWebSocketSession. For generic classes, such as lists, please provide serializer explicitly.
    	at kotlinx.serialization.PlatformUtilsKt.serializer(PlatformUtils.kt:28)
    	at io.ktor.client.features.json.serializer.KotlinxSerializer.lookupSerializer(KotlinxSerializer.kt:64)
    	at io.ktor.client.features.json.serializer.KotlinxSerializer.read(KotlinxSerializer.kt:55)
    	at io.ktor.client.features.json.JsonFeature$Feature$install$2.invokeSuspend(JsonFeature.kt:64)
    	at io.ktor.client.features.json.JsonFeature$Feature$install$2.invoke(JsonFeature.kt)
    	at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:248)
    	... 31 more
    e
    3 replies · 2 participants
  • d

    dave08

    12/02/2018, 7:20 AM
    It would be great for Ktor to provide components needed in microservice architectures, something like this http://link.oreilly.com/gI0uRQW0W00aMS0rF000Xg2, that is java, but it might be nice to take ideas (from the annotations) and adapt them to a dsl in ktor... kubernetes and Istio are also being widely adopted by companies big and small.
    k
    f
    7 replies · 3 participants
Powered by Linen
Title
d

dave08

12/02/2018, 7:20 AM
It would be great for Ktor to provide components needed in microservice architectures, something like this http://link.oreilly.com/gI0uRQW0W00aMS0rF000Xg2, that is java, but it might be nice to take ideas (from the annotations) and adapt them to a dsl in ktor... kubernetes and Istio are also being widely adopted by companies big and small.
k

kenkyee

12/02/2018, 1:24 PM
It has a lot of the things needed... There are a few pending in the issues list too..e.g., OpenTracing. Missing batch jobs in that list I think. What else?
Batch jobs are probably better done with Quartz
d

dave08

12/02/2018, 2:08 PM
Quartz?
@orangy Any chance Ktor will be headed towards microservices like this, or are there other plans?
k

kenkyee

12/02/2018, 2:22 PM
http://www.quartz-scheduler.org
f

Francois Stiennon

12/16/2020, 10:45 AM
hey @kenkyee for opentracing, see https://github.com/zopaUK/ktor-opentracing
k

kenkyee

12/16/2020, 11:39 AM
Nice... Didn't know that was added. 🙂
View count: 2