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
server
  • p

    Pypdeveloper

    04/29/2020, 7:46 AM
    Anyone know how I can web scrape with Kotlin
    l
    7 replies · 2 participants
  • i

    Imran

    04/29/2020, 9:42 AM
    I am trying to get static files it is working with file extensions like
    /static/xyz.json
    but I want access it like
    /static/xyz
    using ktor. can anyone know how to do it?
    1 reply · 1 participant
  • a

    AnnoymousGiraf

    04/30/2020, 1:20 AM
    Hello, any recommendation for tool that it is easy to integrate with for performance testing. for example gatling but it is written in scala and SBT and thus hard to adopt for Kotlin developers/ Java using gradle only. (trying to avoid magic tricks)
    j
    j
    3 replies · 3 participants
  • j

    Jeremy Rouet

    05/01/2020, 2:51 PM
    Hi everybody, to migrate database during the startup, wich library do you advice me? I work uselly with Flyway. My application is write with Ktor, and my database is mySQL
    m
    c
    +1
    5 replies · 4 participants
  • j

    Jeremy Rouet

    05/04/2020, 4:57 PM
    Hi everybody, Did you already implement Swagger with ktor?
    ➕ 1
    1 reply · 1 participant
  • j

    Jeremy Rouet

    05/06/2020, 5:00 PM
    Hi, i have a big issue with my multitenant application in Ktor. I store the context in the ThreadLocal with the "asContextElement". please find un attachement. But sometime, when the function is suspended the context is lost... Any idea ?
    import io.ktor.application.ApplicationCall
    import io.ktor.request.header
    import kotlinx.coroutines.asContextElement
    
    const val TENANT_HEADER_VALUE = "tenantID";
    const val TENANT_HEADER_URL_VALUE = "tenantURL";
    const val CLIENT_HEADER_URL_VALUE = "clientURL";
    const val TENANTID_DEFAULT_VALUE = "master"
    
    object ContextManager {
        private val context = ThreadLocal<Context>();
    
        /**
         * Register a request in the context
         */
        fun registerCall(call: ApplicationCall) {
    
            var requestContext = getContext();
    
            var tenantID = call.request.header(TENANT_HEADER_VALUE);
            LOGGER.trace("Find ${tenantID} in ${call.request.headers}")
            if (tenantID == null || tenantID.isEmpty()) {
                tenantID = TENANTID_DEFAULT_VALUE;
            }
            requestContext.tenantID = tenantID;
            requestContext.tenantUrl = call.request.header(TENANT_HEADER_URL_VALUE).toString();
            requestContext.clientURL = call.request.header(CLIENT_HEADER_URL_VALUE).toString();
    
    
            setContext(requestContext);
        }
    
        fun setContext(context: Context) {
            this.context.set(context);
            this.context.asContextElement(context);
        }
    
        fun getContext(): Context {
            var requestContext = context.get();
            if (requestContext == null) {
                requestContext = Context()
            }
            return requestContext;
        }
    
        fun declareContext(tenantID: String, tenantUrl: String = "", clientURL: String = "") {
            val requestContext = getContext();
            requestContext.tenantUrl = tenantUrl;
            requestContext.tenantID = tenantID;
            requestContext.clientURL = clientURL;
        }
    
    }
    
    class Context {
        var tenantID = TENANTID_DEFAULT_VALUE;
        var tenantUrl = "";
        var clientURL = "";
    }
    c
    d
    12 replies · 3 participants
  • m

    Mike Conley

    05/09/2020, 1:41 PM
    Exception in thread "main" java.lang.IllegalArgumentException: Could not find column mapper for type 'T' of parameter 'parameter #1 value of fun <init>(kotlin.String, T): io.execvision.profile.db.StupidThing<T>' for constructor 'fun <init>(kotlin.String, T): io.execvision.profile.db.StupidThing<T>'
    	at org.jdbi.v3.core.kotlin.KotlinMapper$resolveConstructorParameterMapper$2.get(KotlinMapper.kt:197)
    	at org.jdbi.v3.core.kotlin.KotlinMapper$resolveConstructorParameterMapper$2.get(KotlinMapper.kt:51)
    	at java.util.Optional.orElseThrow(Optional.java:290)
    	at org.jdbi.v3.core.kotlin.KotlinMapper.resolveConstructorParameterMapper(KotlinMapper.kt:196)
    	at org.jdbi.v3.core.kotlin.KotlinMapper.specialize0(KotlinMapper.kt:98)
    	at org.jdbi.v3.core.kotlin.KotlinMapper.specialize(KotlinMapper.kt:73)
    	at org.jdbi.v3.core.result.ResultSetResultIterator.<init>(ResultSetResultIterator.java:38)
    	at org.jdbi.v3.core.result.ResultIterable.lambda$of$0(ResultIterable.java:54)
    	at org.jdbi.v3.core.result.ResultIterable.stream(ResultIterable.java:228)
    	at org.jdbi.v3.core.result.ResultIterable.collect(ResultIterable.java:284)
    	at org.jdbi.v3.sqlobject.statement.internal.ResultReturner$CollectedResultReturner.mappedResult(ResultReturner.java:267)
    	at org.jdbi.v3.sqlobject.statement.internal.SqlQueryHandler.lambda$configureReturner$0(SqlQueryHandler.java:54)
    	at 
    ...
    1 reply · 1 participant
  • k

    Kirill Prybylsky

    05/10/2020, 11:58 AM
    Hello everyone, I am trying to implement websocket feature with ktor, but I only get 404 for the http://localhost:8080/ request in browser. Could you, please, tell me what can be wrong? Here is my websocket implementation:
    webSocket("/") {
        while (true) {
            delay(3000)
            outgoing.send(Frame.Text("hi"))
        }
    }
    f
    a
    +1
    16 replies · 4 participants
  • e

    evanchooly

    05/13/2020, 5:50 PM
    consider using
    zt-exec
    . while the built in libs could probably use some help,
    zt-exec
    is really quite nice.
    j
    1 reply · 2 participants
  • c

    Carlos Fau

    05/15/2020, 12:06 AM
    Hi, I'm very exited with KTor and I'm using it for several microservices. I created a Feature to integrate prometheus metrics on the http server. It was very easy. Then I created a Feature for the client side, but I got a little confused with the client pipelines and which is the best place to add the interceptor for measure total request time. I want to add to the measure the returned status code from the http response. Any help to understand pipelines and the proper place to inject metrics will be welcome.
    k
    1 reply · 2 participants
  • s

    Saša Šijak

    05/15/2020, 6:47 AM
    Anybody tried to emulate something like Styled Components from React world but while server rendering pages on kotlin server. With something like kotlinx.html and a css dsl?
    d
    1 reply · 2 participants
  • r

    Ryan

    05/17/2020, 1:03 PM
    Does anyone have any tips for proguarding kotlin with ktor?
    s
    1 reply · 2 participants
  • k

    ksinkar

    05/19/2020, 6:44 AM
    Has anyone used JAXB for XPath querying of an XML document successfully? I have been trying to use that on some XML documents. I have used the
    xpath
    CLI tool to query the XML document in question, but with JAXB XPath. I am not getting the same/expected results with JAXB XPath query analyzer. Is there an alternative to JAXB in Kotlin?
    a
    d
    3 replies · 3 participants
  • q

    Qverkk

    05/23/2020, 1:11 PM
    Does anyone have some nice microservice example code? :D if it has an api gateway it would be great to look through. My masters degree paper is about micro services in distributed systems and I’ll make an example app in kotlin :D
    j
    v
    3 replies · 3 participants
  • s

    Sergey Mischenko

    05/24/2020, 11:05 AM
    Is it possible to deploy ktor + websocket to Google engine flexible?
    s
    1 reply · 2 participants
  • m

    Mgkaki

    05/28/2020, 2:38 PM
    In Kotlin SpringBoot Project Can I use some ktor package sources ? Can I use both ktor and springboot packages ?
    n
    r
    3 replies · 3 participants
  • j

    James Fenn

    05/29/2020, 3:08 AM
    Would anyone here happen to know a way to extract the hash/target value from the uri of a GET request? (edit: using Ktor - sorry if this is the wrong place for that; I only just realized this channel wasn't ktor-specific after posting). I've tried logging
    call.request.uri
    and related variables, but it seems that it's getting stripped from the URL. Can't find anything related to this in the documentation (unless I'm looking in entirely the wrong place). Use case: trying to implement an annoyingly nonstandard OAuth process that ends in a redirect to
    <http://some.url/#access_token=xxx>
    2 replies · 1 participant
  • s

    Saša Šijak

    05/29/2020, 11:11 AM
    yeshttps://cloud.google.com/blog/products/application-development/introducing-java-11-on-google-cloud-functions
    👍 5
    t
    n
    2 replies · 3 participants
  • j

    jaguililla

    05/29/2020, 3:13 PM
    TechEmpower just released their latest round (19) of their server middleware benchmark. You can check the results here: https://www.techempower.com/benchmarks
    👍 6
    d
    a
    +1
    5 replies · 4 participants
  • c

    camkadev

    05/30/2020, 12:01 PM
    folks what dependency did you use to send emails and also for email validation?
    n
    r
    +1
    4 replies · 4 participants
  • c

    cmgurba

    06/03/2020, 4:29 PM
    shot in the dark: anyone here use jooq? ever ran into an issue where regenerating jooq files all of a sudden changes your schema files to inherit from
    TableRecordImpl
    instead of
    UpdatableRecordImpl
    ? thinking it has to do with postgres12 since i recently upgraded...
    n
    s
    +2
    6 replies · 5 participants
  • b

    Brian Dilley

    06/13/2020, 9:51 PM
    If you’re creating a Netflix clone then use HLS (Http Live Streaming).
    s
    1 reply · 2 participants
  • p

    parth

    06/18/2020, 7:46 PM
    if y’all have any suggestions or can point me in the right direction, I’d really appreciate it!
    j
    m
    +2
    10 replies · 5 participants
  • n

    niklas

    06/19/2020, 12:52 PM
    Does anyone have experience using Coworker in production? I am always on the lookout for simple persistent work queues using the database. The dependency on Consul is not something I would use, so I would replace it with a different Service Checker, but otherwise it looks pretty interesting from the outside. https://coworker.kungfury.io
    1 reply · 1 participant
  • t

    Tiago Brito

    06/21/2020, 3:35 PM
    Hello! I am looking for some cache library developed in Kotlin Any suggestions?
    e
    d
    +4
    11 replies · 7 participants
  • s

    Sag333ar

    06/24/2020, 3:57 PM
    Greetings. Problem: I can't modify Response headers - Kotlin - Ktor - Jetty Server Attempt: Here is the code which I've tried.
    embeddedServer(Jetty, 9000) {
        install(ContentNegotiation) {
            gson {}
        }
        routing {
            post("/account/login") {
                // 1. Create URL
                val url = URL("<http://some.server.com/account/login>")
                // 2. Create HTTP URL Connection
                var connection: HttpURLConnection = url.openConnection() as HttpURLConnection
                // 3. Add Request Headers
                connection.addRequestProperty("Host", "<http://some.server.com|some.server.com>")
                connection.addRequestProperty("Content-Type", "application/json;charset=utf-8")
                // 4. Set Request method
                connection.requestMethod = "POST"
                // 5. Set Request Body
                val requestBodyText = call.receiveText()
                val outputInBytes: ByteArray = requestBodyText.toByteArray(Charsets.UTF_8)
                val os: OutputStream = connection.getOutputStream()
                os.write(outputInBytes)
                os.close()
                // 6. Get Response as string from HTTP URL Connection
                val string = connection.getInputStream().reader().readText()
                // 7. Get headers from HTTP URL Connection
                val headerFields =  connection.headerFields
                // 8. Get Cookies Out of response
                val cookiesHeader = headerFields["Set-Cookie"]?.joinToString { "${it};" } ?: ""
                // 9. Respond to Client with JSON Data
                call.respondText(string, ContentType.Text.JavaScript, HttpStatusCode.OK)
                // 10. Add Response headers
                call.response.header("Set-Cookie", cookiesHeader)
            }
        }
    }.start(wait = false)
    If step 9 is executed first, step 10- doesn't set the headers to response. If step 10 is executed first, step-9 response body isn't set. How do I send both together - response body & response headers?
    r
    k
    6 replies · 3 participants
  • a

    asad.awadia

    06/26/2020, 2:41 PM
    anybody using JDBI or HikariCP?
    a
    j
    +3
    13 replies · 6 participants
  • r

    Rohit Singh

    06/27/2020, 8:19 AM
    Hi I am new to ktor and working on a sample project. What do you guys use for mysql connection ?
    d
    n
    +3
    8 replies · 6 participants
  • s

    Slackbot

    06/30/2020, 12:17 AM
    This message was deleted.
    a
    b
    2 replies · 3 participants
  • p

    Peter Hsu

    07/08/2020, 6:04 PM
    Hi all! I was wondering if there was a ktor multiplatform server implementation available? I'm hoping to be able to run an embedded server on iOS and Android devices.. I've been looking through the ktor documents but multiplatform only references client code
    f
    b
    +2
    8 replies · 5 participants
Powered by Linen
Title
p

Peter Hsu

07/08/2020, 6:04 PM
Hi all! I was wondering if there was a ktor multiplatform server implementation available? I'm hoping to be able to run an embedded server on iOS and Android devices.. I've been looking through the ktor documents but multiplatform only references client code
f

Foso

07/08/2020, 6:12 PM
There is no multiplatform server, Ktor Server cant be used without the JVM, because it has dependencies on Java/Jvm Code
❤️ 1
p

Peter Hsu

07/08/2020, 6:18 PM
Ok, thanks
b

Big Chungus

07/08/2020, 6:50 PM
Although posix ktor server is in the works
p

Peter Hsu

07/08/2020, 6:57 PM
where is a good place to view that progress?
b

Big Chungus

07/08/2020, 6:57 PM
Can't remember. Try looking for a feature branch on github
n

napperley

07/09/2020, 12:30 AM
Keep in mind that Android doesn't support POSIX.
e

ESchouten

07/15/2020, 7:49 AM
https://github.com/ktorio/ktor/issues/571
b

Big Chungus

07/15/2020, 3:53 PM
https://github.com/JetBrains/kotlin-native/tree/master/samples/echoServer
👍 1
View count: 9