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

    mkobit

    04/26/2018, 6:21 PM
    doesnt look like it with some not-so-in-depth debugging
    📝 1
    d
    • 2
    • 6
  • n

    Nail Gilaziev

    04/26/2018, 6:34 PM
    broken links in the documentation section https://ktor.io/servers/lifecycle.html#developmentengine github 404 returned
    ✅ 1
    👏 1
    📝 1
    d
    • 2
    • 1
  • n

    Nail Gilaziev

    04/27/2018, 7:04 AM
    When following setup tutorial for intellijIdea https://ktor.io/quickstart/intellij-idea.html I saw a strange behavior: Step 6 declares this: Wait a few seconds for Gradle to run, and you should see a project structure like the following (with a few other files and directories): And structure must be like this:

    https://ktor.io/pages/quickstart/intellij-idea/project-structure.png▾

    But actually Idea doesn't create a source sets files and directories. More detailed in thread...
    s
    d
    • 3
    • 16
  • n

    Nail Gilaziev

    04/27/2018, 2:05 PM
    When I'm trying to create fatJar by using
    com.github.jengelman.gradle.plugins:shadow:
    I found in docs two different lines to applying this plugin: 1)
    apply plugin: 'com.github.johnrengelman.plugin-shadow'
    here https://ktor.io/servers/deploy.html#fat-jar-gradle 2)
    apply plugin: "com.github.johnrengelman.shadow"
    here https://ktor.io/quickstart/docker.html#package-an-application-using-gradle What the diferences between them? with second line I succesfully create a fatJar - this is definitely true. ) with first line yesterday I had a problems - but it is not exactly. Message about it I write earlier https://kotlinlang.slack.com/archives/C0A974TJ9/p1524754499000390
    📝 1
    d
    • 2
    • 2
  • n

    Nail Gilaziev

    04/27/2018, 4:15 PM
    Documentation section of deploying to heroku https://ktor.io/servers/deploy.html#heroku does not say anything about modifying build.gradle to add this line of code
    task stage(dependsOn: ['shadowJar'])
    Newbie user can stuck with it a little bit) more info here: https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku#verify-that-your-build-file-is-set-up-correctly
    📝 1
    d
    • 2
    • 27
  • n

    Nail Gilaziev

    04/27/2018, 4:21 PM
    Who can help me with deploying to heroku? I can't understand why it not work. project here https://github.com/nailgilaziev/wsUpper I try to run it locally via comands:
    ./gradlew stage
    heroku local web
    And it works. App available on localhost:8080 After pushing to heroku via
    git push heroku master
    it says that all is okay and write to console this: https://afternoon-sierra-23732.herokuapp.com/ deployed to Heroku I tried to modify
    application.conf
    and change port to 80 and 8080 vice versa. none of the options helped. And now I can't understand what are I'm doing wrong.
    d
    • 2
    • 6
  • u

    ubu

    04/28/2018, 12:00 PM
    Hi there. Is it possible to configurate/simulate a slow server response for the whole ktor project?
    o
    d
    • 3
    • 5
  • c

    Creai

    04/29/2018, 5:37 PM
    Hello, are there any good example ktor apps?
    o
    g
    • 3
    • 4
  • r

    Rafa

    04/29/2018, 9:57 PM
    Is there an intuitive way to use the
    Sessions
    feature with
    Authentication
    ?
    authenticate {
                location<Manual> {
                    authenticate("kchatAuth1") {
                        get {
                            call.respondText("Success")
                        }
                    }
                }
            }
    I only get the
    ApplicationCall
    object once I'm already inside of the
    get {...}
    and at that point checking to see if there's an existing session is too late
    📝 1
    o
    d
    • 3
    • 5
  • v

    v

    04/30/2018, 7:23 AM
    I'm using Locations with a form,
    method=get
    . I can't create the URL with
    locations.href
    because I don't have the
    GET
    parameters, they're filled in by the form. Is there a better way of doing this, or is it just an edge case and I'm better leaving it as a hard-coded string?
    s
    • 2
    • 3
  • m

    mp

    05/01/2018, 4:26 PM
    Would people be interested in a session storage implementation backed by redis? I needed it for a project, but I don't mind open sourcing it. (Unlike the example in https://ktor.io/features/sessions.html, it has tests, and is non-blocking.)
    o
    d
    • 3
    • 11
  • k

    kagomez

    05/01/2018, 9:39 PM
    I know it's not necessary to run the app since the previous steps are working fine
    d
    • 2
    • 28
  • m

    mp

    05/04/2018, 5:17 PM
    When starting a server with port = 0, is there a way to tell what random port it ends up binding to?
    d
    • 2
    • 6
  • j

    Jalerson Lima

    05/09/2018, 7:53 AM
    Hello everybody! Is it possible to use Ktor to build a SOAP client?
    k
    • 2
    • 1
  • d

    dave08

    05/10/2018, 12:26 PM
    Also, is there a sample for doing a file download w/ it (or even better
    recieveFile
    in response object...)?
    d
    • 2
    • 3
  • m

    Marcin Wisniowski

    05/10/2018, 11:25 PM
    Hello, I'm sorry if this is a stupid question, but I fail to understand if I can use ktor to make a website? All the examples I see are just returning plain text to requests, while a website would be made of many HTML files. I think I'm looking for a PHP replacement but am very confused with all the things I am finding. I just want to make a website, but using Kotlin instead of PHP. Is ktor what I'm looking for? If not what is?
    k
    • 2
    • 2
  • j

    jk2018

    05/11/2018, 2:29 PM
    or is there a way for me to add new file-ending --> mimeType mappings without modifying the source?
    d
    • 2
    • 13
  • b

    brabo-hi

    05/12/2018, 6:24 AM
    does Ktor plan to support graphql
    a
    j
    r
    • 4
    • 5
  • d

    Deactivated User

    05/14/2018, 8:42 AM
    ^ @brabo-hi
    b
    • 2
    • 3
  • a

    anli

    05/15/2018, 10:23 AM
    Hm.. Can not believe it is impossible to set custom headers for HTTP client 🙂 I try elaborate my issue. So, I play with this code:
    val response = client.call("some/url") {
            contentType(ContentType.Application.Json)
            method = <http://HttpMethod.Post|HttpMethod.Post>
            headers = HeadersBuilder ()
            body = data
        }
    But compiler climes "Val can not be reassigned" against
    headers
    . So. how are you settings custom client headers?
    ✅ 2
    📝 1
    o
    e
    d
    • 4
    • 9
  • m

    mkobit

    05/15/2018, 8:41 PM
    haven't tried it or looked too much in depth yet, but do the ktor client libraries support talking to unix sockets?
    d
    • 2
    • 6
  • m

    Marcin Wisniowski

    05/16/2018, 6:18 PM
    Hello, I'm having a weird issue with sessions. They work fine when I use the in-memory storage, but when I switch to directory storage my requests start crashing with
    java.util.NoSuchElementException: No session data found for id
    , no code in the stack trace is my code so I have no idea what I'm doing wrong.
    o
    • 2
    • 4
  • f

    fred.deschenes

    05/18/2018, 1:18 PM
    Is there a reason why
    ApplicationConfigValue
    only has the
    getString
    function and not the
    getInt
    ,
    getLong
    , etc from hocon's
    Config
    class?
    d
    • 2
    • 4
  • m

    mp

    05/18/2018, 1:23 PM
    I'd like to observe the outcome of the Authentication feature and set a header accordingly so that the front-end can keep track of whether or not the back-end thinks that there is an authenticated user. (I can't just rely on 401, etc, because some endpoints work with and without an authenticated user.) I can set response headers inside a `SessionAuthenticationProvider`'s
    validate
    , but that only applies when a session is present, so it won't get hit on a request with no session or an invalid session cookie. What would be a better place to apply the header that can access
    call.authentication.principal()
    or equivalent, yet will also get called on requests without sessions, etc?
    d
    • 2
    • 7
  • n

    nyxcode

    05/18/2018, 1:42 PM
    Hey! the ktor gson module only responds with application/json when the client asks for it. Is there a way to change this behavior?
    d
    • 2
    • 3
  • t

    ti4n

    05/20/2018, 3:24 AM
    Do you install Locations?
    z
    a
    n
    • 4
    • 8
  • m

    mp

    05/21/2018, 8:41 PM
    I needed CSRF protection for a Ktor service, and didn't find anything out there, so I made a little library. https://bitbucket.org/marshallpierce/ktor-csrf/src/master/ I'm not sure I'm wiring it into the pipeline correctly; does this look right? https://bitbucket.org/marshallpierce/ktor-csrf/src/3ff20b83033890facd74e4983829e287841e6533/src/main/kotlin/org/mpierce/ktor/csrf/CsrfPrevention.kt#lines-41
    d
    • 2
    • 2
  • m

    Marcin Wisniowski

    05/22/2018, 12:50 AM
    The actual response to the request is sent immediately, the delayed query doesn't affect anything other than the database
    d
    • 2
    • 2
  • l

    leus

    05/22/2018, 8:28 PM
    Question: when trying the Chat sample application using two browsers in the same computer, I get messages sent only to one of such browsers
    d
    • 2
    • 18
  • c

    chirag

    05/23/2018, 7:29 AM
    Hi Can anybody explain the difference between using field
    @field:JsonProperty("foo")
    and without field
    @JsonProperty("foo")
    When should i use when
    g
    • 2
    • 3
Powered by Linen
Title
c

chirag

05/23/2018, 7:29 AM
Hi Can anybody explain the difference between using field
@field:JsonProperty("foo")
and without field
@JsonProperty("foo")
When should i use when
g

gildor

05/23/2018, 7:32 AM
First one annotates field of property.
Second one annotate element depending on context
Check official docs https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets
If you don't specify a use-site target, the target is chosen according to the @Target annotation of the annotation being used. If there are multiple applicable targets, the first applicable target from the following list is used:

param;
property;
field.
💯 2
View count: 4