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
  • a

    aeruhxi

    03/20/2018, 5:40 AM
    What is the difference between Exposed and squash (SQL libraries)?
    q
    a
    +1
    3 replies · 4 participants
  • e

    Erick House

    03/20/2018, 6:26 PM
    authentication { 
                    // challenge (pre configured auth) all sub routes and by challenging it       somehow gets redirected to the login page
                    // I don't have access to the application call in the auth pipeline to redirect
                    route("account"){
                        
                    }
                    route("admin"){
                        
                    }
                }
    d
    2 replies · 2 participants
  • e

    Erick House

    03/21/2018, 1:38 AM
    Are there any examples of using a self signed certificate so https can be used during development? How might I configure the server to use it?
    d
    3 replies · 2 participants
  • t

    Tristan Caron

    03/21/2018, 3:34 PM
    Hello, is possible to have the current running jobs?
    o
    4 replies · 2 participants
  • g

    gyl

    03/23/2018, 9:47 AM
    Hi all 🙂! Can we use .java files in a Ktor project (just to know)?
    g
    2 replies · 2 participants
  • n

    Nail Gilaziev

    03/25/2018, 9:35 AM
    Writing backend without good API documentation - bad practice. Now I use spring kotlin + RestDocs and want to see that ktor in the future have same ability. Description: Spring REST Docs helps you to document RESTful services. It combines hand-written documentation written with Asciidoctor and auto-generated snippets produced with Spring MVC Test. Writing unit tests for testing api and simultaneously generate json payloads and descriptions - is very good approach to have up2date documentation. Additionally RestAuto docs can help for using jdoc for automatically describing fields in json payloads. So question: Does ktor have any plans to make possible to generate Json’s body with payload descriptions via unit test like in Spring Rest Docs? Thanks!
    🤔 1
    👍 1
    r
    5 replies · 2 participants
  • j

    jeremy

    03/28/2018, 11:03 PM
    What is the best format for installing auth across multiple routes but not all routes inside of routing {}?
    n
    o
    5 replies · 3 participants
  • n

    neworldlt

    03/29/2018, 6:36 AM
    I have a project with ktor + mongo, but nothing special here. Both are libraries.
    e
    2 replies · 2 participants
  • j

    jeremy

    03/29/2018, 6:37 PM
    Maybe it could be a Feature where I could install and configure the feature and gain access to it from the ApplicationCall?
    o
    5 replies · 2 participants
  • n

    Nail Gilaziev

    03/31/2018, 5:20 AM
    I want to use ktor with postgresql. No dao frameworks - only raw statements because of dynamic data structure. Which driver is best for use idiomatically with coroutines?
    g
    l
    4 replies · 3 participants
  • n

    noncom

    04/01/2018, 11:58 AM
    Hello, I am experimenting with the Ktor autoreload feature. I specify my
    module
    as a function reference (not as a labmda), as instructed, and set the
    watchPaths
    to my projects directory. When I launch the server, it shows a bunch of
    ... DEBUG ktor.application - Watching ...
    messages with all the paths that are in the specified directory. So I suspect, it initializes ok. However, when I change anything in any of these files, there's no reaction from Ktor, no reloading, and not even an error or debug message.
    o
    f
    8 replies · 3 participants
  • q

    qweryt

    04/03/2018, 4:20 PM
    Hi. Anyone can help me to understand how "param" builder works?
    fun main(args: Array<String>) {
        val server = embeddedServer(Netty, 9995) {
            install(DefaultHeaders)
            install(Compression)
            install(CallLogging)
    
            routing {
                route("test") {
                    param("error") {
                        handle {
                            call.respondText { "error" }
                        }
                    }
    
                    get {
                        call.respondText { "test" }
                    }
                }
            }
        }
    
        server.start()
    }
    If I understand correctly, then when I'm going to http://localhost:9995/test?error=123 I should get "error", but I'm getting "test".
    d
    o
    5 replies · 3 participants
  • a

    alex

    04/05/2018, 11:01 PM
    what is the major difference between Ktor and http4k.org?
    u
    c
    +1
    4 replies · 4 participants
  • f

    frellan

    04/06/2018, 8:05 PM
    Yeah I have not gotten the autoreload to work either, do not understand it
    j
    11 replies · 2 participants
  • n

    Nail Gilaziev

    04/07/2018, 4:35 PM
    I studying ktor chat sample app and websockets in general, and I see there a synchronizing blocks and ConcurentHashMaps so the question arises: Firstly I think that ktor works on single thread if no other thread is explicitly started. it seems I was wrong. Where I can read about how requests scheduled in ktor? It necessary to understand chat sample app and why there concurent used
    1 reply · 1 participant
  • p

    Pere Casafont

    04/09/2018, 7:29 AM
    is there a way to have the routing and different application setups split in different files? big applications are much harder to maintain if everything must go in the same file
    s
    r
    11 replies · 3 participants
  • r

    Robert Menke

    04/10/2018, 2:46 AM
    Here’s a small example:
    package app
    
    import freemarker.cache.ClassTemplateLoader
    import io.ktor.application.*
    import io.ktor.features.CallLogging
    import io.ktor.features.DefaultHeaders
    import io.ktor.freemarker.FreeMarker
    import io.ktor.freemarker.FreeMarkerContent
    import io.ktor.http.*
    import io.ktor.response.*
    import io.ktor.routing.*
    import io.ktor.sessions.Sessions
    import io.ktor.sessions.cookie
    import io.ktor.websocket.WebSockets
    import session.AuthenticatedSession
    import sockets.SecureSocketServer
    import java.time.Duration
    
    fun Application.main() {
        install(DefaultHeaders)
        install(CallLogging)
        //<https://ktor.io/features/sessions.html#install-basic>
        install(Sessions) {
            cookie<AuthenticatedSession>(AuthenticatedSession.NAME)
        }
        //<https://ktor.io/features/freemarker.html>
        install(FreeMarker) {
            templateLoader = ClassTemplateLoader(Application::class.java.classLoader, "templates")
        }
        //<https://ktor.io/features/routing.html>
        routing()
    }
    
    fun Application.routing() {
        install(Routing) {
            get("/") {
                call.respond(FreeMarkerContent("index.ftl", mapOf("test_name" to "World")))
            }
        }
    }
    j
    2 replies · 2 participants
  • l

    leonhardt

    04/10/2018, 3:27 AM
    I'm trying to implement a new engine that processes requests for contract tests, based on information available in memory (or provided on configuration). I've been going through the Apache and Jetty engine source files to understand how the Ktor client engine APIs work, but I've been struggling to reverse engineer the purpose of all the pieces. Can anyone familiar with how the engines work talk me through it or give me a push in the right direction? CC: @e5l
    e
    1 reply · 2 participants
  • m

    mp

    04/11/2018, 3:38 PM
    I'm just starting out with ktor so maybe I'm missing something obvious, but I'm wondering how I can go about structuring more complex endpoints across classes, and the "Extracting Routes" code sample appears to be identical to the starter Hello World above it. https://ktor.io/servers/structure.html 🤔 What I'd like would be a way to have a class (an implementation of
    PipelineInterceptor
    ?) handle processing for a given path.
    d
    19 replies · 2 participants
  • j

    jk2018

    04/11/2018, 7:20 PM
    Having some trouble with a ktor app. It works all fine until I enable auto-refresh. Any idea what would cause this? ( More detail here: https://stackoverflow.com/questions/49782953/enabling-ktor-auto-reload-breaks-the-app )
    n
    7 replies · 2 participants
  • f

    Felix

    04/12/2018, 10:47 PM
    Hi. Where can I find more information about the HTTP client design in ktor? I'm particularly curious on the reasons behind some of the decisions on Apache-based client, namely the design of the ApacheResponseConsumer and the motivation for the backendChannel.
    e
    e
    3 replies · 3 participants
  • a

    Aharon

    04/13/2018, 8:56 AM
    Hi, really excited about the HttpClient as well. Was reading the online docs and I was just wondering, is there a built in way of adding Form data for the POST body (something like key1=val1&key2=val2) as a map instead of just encoding this myself into a text body?
    e
    2 replies · 2 participants
  • a

    Aharon

    04/13/2018, 9:29 AM
    Actually after think about this abit more, I was wondering... There's already an awesome fully featured HttpClient lib in Kotlin called Fuel (https://github.com/kittinunf/Fuel) Was it considered to incorporate this into Ktor instead of building a new Http client from the bottom up?
    s
    r
    4 replies · 3 participants
  • o

    otakusenpai

    04/13/2018, 12:51 PM
    i was following the code examples from here https://ktor.io/servers/raw-sockets.html
    d
    13 replies · 2 participants
  • a

    aeruhxi

    04/16/2018, 11:30 AM
    yes I tried importing everything intellij suggested
    k
    1 reply · 2 participants
  • d

    danielm

    04/16/2018, 12:35 PM
    Hi all, I'm new to ktor and kotlin in general. Hope this question has not been asked too many times: how can environment variables be defined for the tests?
    d
    6 replies · 2 participants
  • u

    uli

    04/16/2018, 7:22 PM
    Hi Guys, does the ktor client support streaming, suspending downloads? I just realised, that
    IncomingContent
    can produce a
    ByteChannel
    , but not not an
    asynchronousByteChannel
    d
    2 replies · 2 participants
  • a

    aeruhxi

    04/17/2018, 10:44 AM
    Just updated to
    0.9.1
    . Same error
    d
    1 reply · 2 participants
  • u

    uli

    04/18/2018, 7:49 AM
    Hi Guys, i am having trouble installing
    BasicAuth
    as client feature. I do:
    val apacheEnbgineFactory = Apache.config {
            followRedirects = true
        }
    
        val ktorClient = HttpClient(apacheEnbgineFactory) {
            install(BasicAuth) {
                username = "test"
                password = "test"
            }
        }
    Trying to break inside the block passed to
    intercept
    inside BasicAuth does never break
    e
    3 replies · 2 participants
  • u

    uli

    04/18/2018, 7:53 AM
    btw. I copied BasicAuth as source code from github as the gradle artefact
    io.ktor:ktor-client-features:0.9.1
    seems to be empty
    e
    2 replies · 2 participants
Powered by Linen
Title
u

uli

04/18/2018, 7:53 AM
btw. I copied BasicAuth as source code from github as the gradle artefact
io.ktor:ktor-client-features:0.9.1
seems to be empty
e

e5l

04/18/2018, 8:02 AM
Hey @uli. Please consider using dependency from here https://mvnrepository.com/artifact/io.ktor/ktor-client-auth-basic/0.9.1
u

uli

04/18/2018, 8:38 AM
thx. that works
👍 1
View count: 6