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

    Manuel Pérez Alcolea

    03/08/2023, 2:22 AM
    I'm trying to serialize a
    List
    to JSON as value for a key (
    "items": [ {...}, {...} ]
    ) but I'm getting an array with no key instead (
    [{...}, {...}]
    ). I'm using
    ktor-serialization-kotlinx-json
    , how can I change this behavior?
    @Serializable
    data class Pages(val items: List<...>)
    
    call.respond(listOf(...))
    e
    4 replies · 2 participants
  • h

    helpermethod

    03/08/2023, 7:43 AM
    Hi! I'm trying to wrap my head around
    externalServices
    . Are the mock servcices only called by the client created in the
    testApplicaton
    ? So if I wanted to make use of those in my application, I'd need to pass in the test client as the client used by my service? The documentation is a little bit unclear.
    a
    2 replies · 2 participants
  • s

    Shubham Singh

    03/08/2023, 5:35 PM
    Is there a way to collect a flow inside the
    webSocket
    block in Ktor Server and
    sendSerialized
    the values collected from that flow? In my case, I am observing the changes inside my PostgreSQL DB and returning the changes as a flow from the repository. Now I want to send this flow of values through a websocket connection so that whenever the value inside the flow changes, my websocket also sends a new frame, but right now when I try to do the following:
    webSocket(getObservable) {
                        safeCall {
                            val id = call.parameters["id"]
                            repository.getObservable(id = UUID(id)).collect { value ->
                                sendSerialized(value)
                            }
                        }
                    }
    the websocket connection closes as soon as I connect to it.
    a
    a
    +1
    7 replies · 4 participants
  • m

    Marcin Wisniowski

    03/08/2023, 6:29 PM
    I'm trying to migrate my custom Feature into the new Plugin API, but I can't find what is the new equivalent of:
    pipeline.environment.monitor.subscribe(Routing.RoutingCallStarted) { it: RoutingApplicationCall
        it.route[..]
    }
    Where should I look?
    r
    4 replies · 2 participants
  • s

    steamstreet

    03/08/2023, 11:51 PM
    Is there a way to create a Url relative to another Url? I have a URL: http://www.somedomain.com/page and another relative path:
    /someotherpage
    but short of dissecting the URLs, there doesn’t seem to be a way to create one like there is in the JDK:
    URL(URL("<http://www.somedomain.com/page>"), "/someotherpage")
    s
    r
    6 replies · 3 participants
  • e

    Emirhan Emmez

    03/09/2023, 8:27 AM
    Hi all, I saw an issue on YouTrack about one Ktor bug that I had the same: https://youtrack.jetbrains.com/issue/KTOR-5227 I saw your comment. Is there any fix about it? My dependency tree:
    plugins {
        id 'com.android.application' version '7.4.2' apply false
        id 'com.android.library' version '7.4.2' apply false
        id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
        id 'com.google.dagger.hilt.android' version '2.44' apply false
        id 'org.jetbrains.kotlin.jvm' version '1.8.10' apply false
    }
    Ktor version: 2.2.4 JDK version: 11 My Network module:
    @Provides
    @Singleton
    fun createKtorClient(): HttpClient =
         HttpClient(Android).config {
             defaultRequest {
                 url("<http://localhost:8080/>")
                 contentType(ContentType.Application.Json)                
                 accept(ContentType.Application.Json)
             }
             install(Logging) {
                 level = LogLevel.ALL
             }
             install(ContentNegotiation) {
                 json()
             }
            }
    a
    1 reply · 2 participants
  • j

    Jonas TM

    03/09/2023, 12:33 PM
    OpenAPI
    Swagger
    Ktor provides plugins for OpenAPI and Swagger. However the documentation is quite limited. Is there currently any way to add information to the documentation like general API infos and single endpoint descriptions? Both plugins also seem to ignore the
    POST
    body definitions, is this a known problem?
    e
    v
    24 replies · 3 participants
  • a

    AmrJyniat

    03/09/2023, 2:50 PM
    Hi, a Ktor newbie here I've hard time with post fun, I'm getting
    400 Bad request
    always even I doubled checked on the request data, the code and details in 🧵
    s
    5 replies · 2 participants
  • s

    Slackbot

    03/09/2023, 7:00 PM
    This message was deleted.
    y
    1 reply · 2 participants
  • s

    Sergey Aldoukhov

    03/09/2023, 7:42 PM
    Just curious, how Ktor was named, what is the name origin?
    m
    l
    +1
    9 replies · 4 participants
  • a

    Amir hossein Abdolmotallebi

    03/10/2023, 9:48 PM
    Hello guys does ktor have problem with idea plugin development?
    1 reply · 1 participant
  • a

    Adam Brown

    03/10/2023, 10:07 PM
    I'm using Bearer Token auth with the ktor client, but cant quite figure this out: when i login in and get my new token i save it to storage. but the
    HttpClient
    it's self doesn't know it needs to call it's
    loadTokens
    again, is there anyway to get it to reload it's tokens after a login?
    o
    2 replies · 2 participants
  • a

    Arun Joseph

    03/11/2023, 7:51 PM
    I am a newcomer to ktor, I use the following for cookie management at client side,
    private val cookieStorage: CookiesStorage = AcceptAllCookiesStorage()
        private val client = HttpClient(engine) {
            expectSuccess = true
            install(ContentNegotiation) {
                json(
                    Json {
                        ignoreUnknownKeys = true
                        prettyPrint = true
                    }
                )
            }
            install(HttpCookies) {
                cookieStorage
            }
        }
    How can I manually clear the cookie stored by HttpCookies?
    a
    1 reply · 2 participants
  • f

    Francis Mariano

    03/11/2023, 10:24 PM
    hello everyone. Is it possible to implement a server running a websocket and normal api??? For example, I want create a api with POST method which sending a message for a client via websocket.
    b
    c
    +1
    6 replies · 4 participants
  • b

    borisdamato

    03/13/2023, 4:40 PM
    Hi all, how can I create a client plugin/interceptor that reads the response with
    bodyAsText
    without interfering with other plugins that might want to do the same? At the moment I see that the body can only be read once, after which it gets consumed. Is there a way to prevent that? Thanks
    c
    a
    12 replies · 3 participants
  • a

    ayodele

    03/14/2023, 8:45 AM
    Hello. Is it optimal to save `DefaultWebsocketSession`'s as List in memory on the Ktor server?? Like in the chat example
    j
    1 reply · 2 participants
  • d

    dave08

    03/14/2023, 2:50 PM
    What's the recommended way to set a timeout on an endpoint in a Ktor Server?
    a
    c
    9 replies · 3 participants
  • p

    Pavel Kunyavskiy [JB]

    03/14/2023, 4:20 PM
    Hi. What is a good way to answer http get query with stream of events. I mean, no content length, infinity long living query, which sometime print a line to output, if client is still there. call.respondOutputStream with explicit flushes seams to be working, but doesn't look suspend friendly. Won't it block more threads than needed?
    a
    4 replies · 2 participants
  • q

    Quap

    03/15/2023, 6:08 AM
    Is there a way to reliably determine whether an incoming request is coming from a local connection? I want to make an admin panel that is accessible from the machine hosting the server only, but I see the warning about using call.request.local.remoteAddress...
    a
    6 replies · 2 participants
  • m

    Marcus Cvjeticanin

    03/15/2023, 4:01 PM
    Hi Ktor developers! I'm trying to put together a GitHub repo to collect good resources for Ktor developers. I'm continuously adding good links I can find. If you have something to contribute please fork and send a pull request so we all can learn a bit more about this awesome framework. Thanks in advance! GitHub: https://lnkd.in/en6XYiEW
  • a

    Anders Kirkeby

    03/15/2023, 6:10 PM
    Hi all - I'm at a loss when it comes to the OAuth module with Ktor. I've based my code off of the ktor-sample project auth-oauth-google however, I'm using Strava as my OAuth provider. The login route works, redirects to Strava and with the help of some logging I can see that the
    authorization_code
    is returned, and then the token-request is issued witch results in a 200 OK with both the access and refresh token being returned in the body. So everything seems to be good on the strava-side. However, the subsequent callback to
    /login/authorization-callback
    returns a 401 - which I for the life of me cannot understand. Do any of you have any pointers, or know of any issues with CIO (or something 🤷 ) Code added in the following thread :heart_hands:
    a
    5 replies · 2 participants
  • b

    brabo-hi

    03/16/2023, 5:59 AM
    Hi guys, what is the best way to get the number of active connect to a ktor server application
    q
    2 replies · 2 participants
  • g

    Gabriel Luchtenberg

    03/16/2023, 7:10 PM
    Hey, anyone using annotations to create an openapi file from the request dtos?
    r
    2 replies · 2 participants
  • f

    Fred Friis

    03/16/2023, 8:23 PM
    # How is Ktor different? Hi all! I'm joining a team that uses Ktor and I'm trying to get a grip on what distinguishes it from other frameworks. ---> continued in thread
    c
    p
    +1
    4 replies · 4 participants
  • q

    Quap

    03/16/2023, 9:41 PM
    Is there an easy way to contribute to or make suggestions for the docs? There are some things that I've come across there that are a bit ambiguous or could benefit from more context and I'd like to help
    a
    2 replies · 2 participants
  • q

    Quap

    03/16/2023, 9:56 PM
    Can IP address be spoofed when reading ApplicationRequest.local.remoteAddress but Forwarded Headers plugin is not installed?
  • n

    neerav

    03/17/2023, 11:18 AM
    Hello Can anyone please guide me or share document to learn on below Point related to Ktor Client 👇 In my application there could be 3 different HOST URLs. And 1 will be default which is used by default. Is there any way we can keep the URL dynamically ? Thanks
    a
    1 reply · 2 participants
  • c

    Charles Maina

    03/17/2023, 11:42 AM
    Hi all .. I have been getting this 404 error response when trying to return a serialized data class using kotlin serialization.
    "Skipping response body transformation from HttpStatusCode to OutgoingContent for the POST /register request because the HttpStatusCode type is ignored. See [ContentNegotiationConfig::ignoreType]". Anyone knows how I can go about it? I have tried searching online first.
    This is how I am installing content negotiation.
    fun Application.configureSerialization() {
        install(ContentNegotiation) {
            json()
        }
    }
    a
    6 replies · 2 participants
  • m

    Manasseh

    03/17/2023, 2:07 PM
    Hey guys! I've been having issues setting up swagger UI for my project. I have the dependency listed, and paths set, but for some reasons, I keep getting an error "Failed to load API definition". You can find screenshots of my setup
    j
    a
    11 replies · 3 participants
  • a

    Arjan van Wieringen

    03/18/2023, 9:04 AM
    I have trouble finding good documentation about configuring the output from the OpenAPI generator. It typically adds Examples and things like Server URL's that I am not happy with. Is there a way to overwrite these defaults?
    j
    2 replies · 2 participants
Powered by Linen
Title
a

Arjan van Wieringen

03/18/2023, 9:04 AM
I have trouble finding good documentation about configuring the output from the OpenAPI generator. It typically adds Examples and things like Server URL's that I am not happy with. Is there a way to overwrite these defaults?
j

Jonas TM

03/18/2023, 11:57 AM
In case your are referring to the IDE generator the customization is still limited https://kotlinlang.slack.com/archives/C0A974TJ9/p1678365232415359?thread_ts=1678365232.415359&amp;cid=C0A974TJ9
a

Arjan van Wieringen

03/18/2023, 3:16 PM
So basically it is not very usable. Looking at the issues linked it is actually in alpha status
View count: 2