https://kotlinlang.org logo
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
http4k
  • d

    dave

    08/13/2019, 7:49 AM
    @Dmitry Kandalov it's been a while now, but I seem to recall that it was added purely as an aid to testing, so the order of added headers was disregarded when performing a comparison. I for one have never actually ever used it in prod code.
    u
    • 2
    • 4
  • r

    Ricardo

    08/27/2019, 4:01 PM
    Hey sorry to pester the channel, but could someone take a look at this PR please: https://github.com/http4k/http4k/pull/277
    d
    • 2
    • 27
  • r

    Ricardo

    08/28/2019, 1:14 PM
    New proposal: support for Google Cloud Endpoints
    x-google-endpoints
    extension for OpenAPI: https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#x-google-endpoints
    d
    • 2
    • 16
  • s

    s4nchez

    09/03/2019, 6:58 AM
    @Razi Kheir Unfortunately, that depends a bit on the client implementation. Which one are you using?
    r
    d
    • 3
    • 6
  • d

    dave

    09/06/2019, 5:31 AM
    If anyone wants to chip in with things you've found good (or bad 🙃) when starting off then that would be great: https://www.reddit.com/r/Kotlin/comments/d06za9/ktor_vs_http4k/
    y
    x
    u
    • 4
    • 13
  • d

    dave

    09/10/2019, 4:38 PM
    @Alfi Thanks for your kind words. Looks like you've found a problem - I've raised and fixed #291. The release with it in is 3.180.0 and is releasing now. 🙂
    a
    • 2
    • 2
  • k

    kushalp

    09/12/2019, 10:05 AM
    Has anyone seen this before and know what I'm doing wrong here? Happy to provide a reproducible example
    main.kt
    file if it's useful.
    d
    j
    • 3
    • 12
  • k

    kushalp

    09/12/2019, 10:57 AM
    Does the order matter when applying filters? Is there any significant difference in the order that server, request, and response filters need to be applied?
    d
    • 2
    • 3
  • d

    dave

    09/17/2019, 12:01 PM
    we can't use nulls to generate a valid schema, so we blow up
    r
    • 2
    • 2
  • d

    dave

    09/18/2019, 2:53 PM
    if you use the API, it should handle all that for you
    r
    • 2
    • 11
  • d

    dave

    09/27/2019, 11:24 AM
    @RajanS it should be working fine. when you say "in the swagger" - do you mean the JSON doc (say the example section of the definition), or are you having problems with the actual marshaling of the service? A Gist showing what you're seeing would help to diagnose if there is a problem
    r
    • 2
    • 19
  • a

    Anil

    09/28/2019, 9:59 PM
    Hi David, Im getting the following exception after upgrading from
    3.179.0
    to 3.185.0`
    Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Class.getPackageName()Ljava/lang/String;
    	at org.http4k.core.MimeTypes$Companion.loadStandard(MimeTypes.kt:29)
    	at org.http4k.core.MimeTypes$Companion.access$loadStandard(MimeTypes.kt:12)
    	at org.http4k.core.MimeTypes$Companion$standardTypes$2.invoke(MimeTypes.kt:16)
    	at org.http4k.core.MimeTypes$Companion$standardTypes$2.invoke(MimeTypes.kt:12)
    	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    	at org.http4k.core.MimeTypes$Companion.getStandardTypes(MimeTypes.kt)
    	at org.http4k.core.MimeTypes$Companion.invoke(MimeTypes.kt:14)
    	at org.http4k.routing.ResourceLoadingHandler.<init>(internal.kt:24)
    	at org.http4k.routing.StaticRoutingHttpHandler.<init>(internal.kt:55)
    	at org.http4k.routing.StaticRoutingHttpHandler.<init>(internal.kt:48)
    	at org.http4k.routing.RoutingKt.static(routing.kt:57)
    	at com.johnlewis.recommendations.controller.ApiHandler.invoke(ApiHandler.kt:111)
    	at com.johnlewis.recommendations.Application.<init>(Application.kt:57)
    	at com.johnlewis.recommendations.ApplicationKt.main(Application.kt:89)
    	at com.johnlewis.recommendations.ApplicationKt.main(Application.kt)
    This happens for StaticRoutingHandler serving static content.
    d
    x
    • 3
    • 8
  • x

    xuemin.guan

    09/30/2019, 10:31 AM
    hi guys, I wonder what battle tested http client anyone can recommend to use in our http4k app. We started off with OkHttp. One team reported problems: 1. The default
    org.http4k.client.OkHttp()
    use default OkHttp configuration and it seems it is optimized for single user application. 2. the team moved to creating OkHttp with their customized connection pooling configuration but it does not seem to pass their performance testing in some cases. The team has therefor moved away from OkHttp and started using
    org.eclipse.jetty.client.HttpClient
    . We thought to use
    org.eclipse.jetty.client.HttpClient
    instead as well given their experience. But thought to seek some recommendation here.
    d
    s
    r
    • 4
    • 17
  • d

    dave

    10/03/2019, 5:48 AM
    @Razi Kheir you can obviously do either, but personally I prefer the path based routing, especially when using the contracts module with OpenApi as it makes it very clear in the docs that both exist and the different request/response types that can be present for each - also this multi-message type is actually something that the swagger UI does not currently support (or at least last time I checked). The approach also makes the overall route handler code easier to read and to test - less logic == simpler. 🙃 . And when it comes time to remove the old routes you can just delete the entire old code instead of having to unpick the switching logic for the latest version from the old.
    r
    • 2
    • 7
  • r

    Razi Kheir

    10/04/2019, 7:22 AM
    I’m having an issue creating a jettyClient with a connection pool. The JettyClient expects an HttpClient while this one returns an object that is a ClosableHttpClient
    -.txt
    d
    • 2
    • 3
  • r

    Razi Kheir

    10/11/2019, 12:36 AM
    Another question, I have the following filters set up on my handler:
    ServerFilters.RequestTracing()
          .then(ServerFilters.SetContentType(ContentType.APPLICATION_JSON))
                .then(logAPIRequestFilter())
                .then(ServerFilters.Cors(corsPolicy))
                .then(NoCache())
                .then(exceptionToErrorResponseFilter())
                .then(lensExceptionFilter())
                .then(apiHandler)
    `
    But for some reason cache control headers are not being returned when I curl (both for responses bigger, smaller than 400 (tried also override and writing true, still didn’t return it)
    d
    • 2
    • 4
  • j

    joscha.alisch

    10/12/2019, 8:08 AM
    Hey folks 🙂 What would be your recommended way of creating an environment config from multiple `EnvironmentKey`s ? Say I want to create an instance of
    data class MongoDBSettings(val host: String, val port: Int)
    from the environment variables
    MONGO_HOST
    and
    MONGO_PORT
    . Would I have them as separate `EnvironmentKey`s and do the mapping outside or is there some lens magic where I can do something like
    EnvironmentKey.mongoSettings().required("MONGO_HOST", "MONGO_PORT")
    ?
    s
    d
    • 3
    • 2
  • r

    Razi Kheir

    10/16/2019, 8:19 AM
    I was wondering something regarding lenses. Should I define a lens such as this:
    Body.auto<RequestBody>().toLens()
    Once as a constant and use it inside of other methods? Or write it inside of a method? I guess what i’m asking if it will be recreated every time in the method with no reason :x
    ➕ 1
    d
    • 2
    • 6
  • r

    Razi Kheir

    10/17/2019, 8:44 AM
    I was wondering how to add RequestTracing to my client (for outgoing calls). Or any other headers. I just want my client to automatically attach some headers to all calls outgoing through it such as tracing, content type, etc. Or can those only be added on the request level I wonder
    d
    • 2
    • 3
  • a

    Anil

    10/17/2019, 1:35 PM
    Hi David, I was wondering how to do percentile metrics using http4k ?
    d
    • 2
    • 1
  • r

    Razi Kheir

    10/21/2019, 5:54 AM
    @dave https://www.http4k.org/cookbook/request_context/ I’m using context key to save/retrieve a context of a request for logging purposes. I was wondering, do you guys pass that context on the main handler of your route and pass it down to relevant methods for logging, or do you pass down the request itself and lens out the context every time you log.
    d
    • 2
    • 9
  • r

    RichyHBM

    10/21/2019, 10:45 AM
    Does http4k have built in DI? Or an easy way to integrate it
    d
    • 2
    • 2
  • k

    kushalp

    10/21/2019, 3:34 PM
    Is anyone using GraphQL with http4k? Have you integrated it successfully with the `Request`/`Response` flow that http4k servers/clients use?
    y
    d
    r
    • 4
    • 9
  • r

    RichyHBM

    10/22/2019, 10:40 AM
    It's for Jade4J fyi
    👍 2
    d
    • 2
    • 10
  • l

    Luis Mirabal

    10/27/2019, 4:35 PM
    Hi, is there a way to add additional behaviour to
    server.start()
    ? so that a connection to a message broker can be established on start, other than implementing the
    Http4kServer
    interface myself
    s
    d
    • 3
    • 7
  • d

    dave

    10/28/2019, 6:02 AM
    @Razi Kheir for the second question, you can use a composite object: https://github.com/http4k/http4k/blob/93071c49e93b74798869721b5dddae9367d33f84/http4k-core/src/test/kotlin/org/http4k/lens/BiDiLensSpecTest.kt#L123
    😀 1
    • 1
    • 1
  • d

    dave

    10/28/2019, 6:05 AM
    For the first, this should definitely work. Could you just put together a tiny example and post it here or in a gist, and we'll take look?
    r
    • 2
    • 4
  • u

    Uberto Barbini

    10/29/2019, 8:59 AM
    I'm playing with KotlinNative for a Demo, is someone ever tried a port of Http4k to KN?
    s
    d
    • 3
    • 17
  • r

    Razi Kheir

    11/07/2019, 3:15 AM
    Hey, I was wondering if it is possible for body auto marshalling lenses to pick up @field:Json. I want to have different name for internal variable vs incoming one, it seems as though ignores that flag and doesnt unmarshal those fields
    d
    • 2
    • 2
  • d

    dave

    11/21/2019, 6:28 AM
    @Razi Kheir you can do either TBH - there are points to be made on either side- a single port gives you the ability to know that your main server instance definitely isn't choking, but you then have internal traffic mixed up with your normal API traffic which can be a security thing (that otherwise needs to be solved another way). If you do want to put them on the same port, you can just compose an instance of
    Health
    into your main routes definition block.
    👍 1
    r
    • 2
    • 1
Powered by Linen
Title
d

dave

11/21/2019, 6:28 AM
@Razi Kheir you can do either TBH - there are points to be made on either side- a single port gives you the ability to know that your main server instance definitely isn't choking, but you then have internal traffic mixed up with your normal API traffic which can be a security thing (that otherwise needs to be solved another way). If you do want to put them on the same port, you can just compose an instance of
Health
into your main routes definition block.
👍 1
r

Razi Kheir

11/21/2019, 6:35 AM
Thanks Dave 🙂
View count: 3