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

    02/08/2021, 4:54 PM
    For anyone interested in http4k-connect.. https://kotlinlang.slack.com/archives/C0BJ0GTE2/p1612803153161600
    👍 1
    r
    f
    d
    • 4
    • 6
  • t

    tkint

    02/08/2021, 5:32 PM
    Hi! I'm working with http4-connect (which is really great btw) and I'm facing an issue. In our organization, there is an on-premise S3 installation on an internal domain. I noticed that http4k-aws and http4k-connect have
    <http://amazonaws.com|amazonaws.com>
    domain hardcoded. When I change the domain with
    ClientFilters.SetHostFrom
    , the signature process seems to fail: I get an AccessDenied response, even if the request is correct. By trying the same request with Postman and its included AWS Signature feature, I got a different
    SignedHeaders
    : • Postman:
    SignedHeaders=host;x-amz-content-sha256;x-amz-date,
    • Http4k-connect:
    SignedHeaders=host;x-amz-date,
    So I think there are those two possibilities, either the signature is wrong due to a late host change, or the signature needs to sign
    x-amz-content-sha256
    too. Either way, it would be nice to be able to set the base domain.
    d
    • 2
    • 5
  • b

    Ben Brodie

    02/10/2021, 6:09 AM
    Hello. I’m loving http4k but I noticed I’m not having luck with exception handling. Normally, when you have an uncaught exception, it will eventually get logged. That doesn’t seem to be happening. I’m using Undertow as my server, but I’m not sure that matters. I saw the
    CatchAll
    filter, but I it looks like that logs the stacktrace to the response, which is not what I would expect or want. I want a 500 status returned on uncaught exception, but I also want a log with the stacktrace. Sure, I can implement this myself with a filter, but I just feel like I’m missing some important piece of the puzzle. Please advise on how to approach exceptions (there will always be exceptions we don’t anticipate, and I want to make sure that these get logged so that in a production system, I can see the stacktrace).
    r
    f
    • 3
    • 4
  • j

    James Richardson

    02/10/2021, 7:54 AM
    As far as I know http4k doesn't do any logging by itself, because it doesn't have dependencies on logging frameworks, and in any case, it doesn't know how you might want to log stuff, or even if you want to. Many people have moved far away from log4j and the like, and instead emit structured events when things happen, just to stdout, that are collected by fluentd or similar. There are a few examples of structured logging in the cookbook https://www.http4k.org/cookbook/structured_logging_with_events/ If you would like to log lines with log4j, slf4j, java logging or whatever its easy to add a filter that uses your local logging library natively. I think there are some examples in https://www.http4k.org/cookbook/monitoring/
    b
    • 2
    • 2
  • d

    dave

    02/10/2021, 8:02 AM
    You can also see structured logging in use in the http4k-by-example repo 🙃. https://github.com/http4k/http4k-by-example/blob/68a56c96cdacaf4567bba74ec910f41b2e44a1af/src/main/kotlin/verysecuresystems/SecuritySystem.kt#L37
    e
    r
    • 3
    • 31
  • d

    Daniel Skogquist Åborg

    02/12/2021, 6:11 AM
    If you use Body.auto() with Gson, and send the JSON literal "null" as body, you get a null out of the lens even though it promises not to return nulls in its contract. Should this be validated by the lens or is it application logic?
    s
    d
    • 3
    • 25
  • v

    Vojtěch Knyttl

    02/16/2021, 2:24 PM
    I am not sure whether it is a bug or feature - consider having lens
    <http://Query.int|Query.int>().required("minValue", "Required minimal value")
    This will nicely generate OpenApi description with
    integer
    definition. This seems to be the result of
    IntegerParam
    in
    mapWithNewMeta(StringBiDiMappings.long(), IntegerParam)
    . However, when using
    .multi
    , this doesn't change, the OpenApi definition stays at
    integer
    . I can se ParamMeta contains also
    ArrayParam
    , so I guess this should ideally result in somehting like
    integer array
    ? If I understand correctly, the
    ArrayParam
    is not used for .
    multi
    and I am not sure how this should be done properly?
    d
    • 2
    • 8
  • n

    Norman

    02/16/2021, 7:48 PM
    Hello, Would anyone have any examples around for implementing micrometer's stackdriver library with http4k? I found the SimpleMeterRegistry to be straight forward but struggling to get the Stackdriver plugin setup. (I apologize if this is trivial, pretty new to Kotlin and the JVM ecosystem..) Thanks!
    d
    • 2
    • 2
  • a

    andyg

    02/17/2021, 3:09 AM
    Hi guys, any examples of using a custom Configuration with a templating engine? I am using freemarker, however the default usage logs a severe error on every call (it's because http4k uses
    Configuration(Configuration.getVersion())
    instead of a specific version:
    Configuration(Configuration.VERSION_2_3_30)
    )... but I am striking out when trying to provide a custom Configuration. Also useful for providing custom string formats, equality checks, etc.
    d
    • 2
    • 7
  • e

    Elizabeth Thomas

    02/18/2021, 4:57 AM
    @dave Is it possible to add the
    OpenApiExtension
    for the
    paths
    in OpenApi spec through http4k-contract? My scenario is that I want to be able to add a custom attribute with a value to every path in my OpenApi Spec. I was able to add a custom attribute block using OpenApiExtension to the
    extensions
    field in
    OpenApi3
    . But I am not sure how to do it for each of my path object
    apiBaseUrl bind contract {
          renderer = OpenApi3(
            ApiInfo(apiName, apiVersion, apiName),
            WdsHttpJackson,
            listOf(XApiDefinitionExtension),
            OpenApi3ApiRenderer(WdsHttpJackson)
          )
          descriptionPath = swaggerJsonPath
          routes += contractRoutes
        }
    d
    • 2
    • 13
  • j

    James Richardson

    02/19/2021, 7:35 AM
    This is a feature of the code that is processing the request body. Assuming you are using json and Jackson, you can do this by making the relevant field not-nullable, or by setting the relevant options in jackson.
    👍 1
    e
    d
    • 3
    • 91
  • s

    Shingi Chanakira

    02/19/2021, 3:46 PM
    I created a basic Hello World app using the http4k generator. I can do a gradle clean build and a jar file is generated. When I try to run the jar file, I get an error that the jar is missing a manifest file. I added a jar tag with a manifest attribute but now I'm getting class loading errors. Anyone know what I'm missing?
    d
    b
    • 3
    • 13
  • r

    Razvan

    02/20/2021, 6:36 PM
    Hi, in a contractRoute I use an object that contains a list of map. the OAS specification declares the map as a SingletonMap but that reference does not exist. there is a JS error in the swagger because of that.
    • 1
    • 2
  • s

    ssr86

    02/21/2021, 12:20 AM
    Hi, does http4k client support receiving SSE? If so, is there any information on how to implement that? I can't seem to find any info on that on the project site (only the server side or so it looks for me)...
    d
    r
    • 3
    • 7
  • d

    dave

    02/21/2021, 2:01 PM
    @Razvan omg. It's a total nightmare. The latest was this morning when we discovered that the new BOM was no longer compatible with any of our projects because of gradle magic. Of course we only found that out today because it took 12 hours for the artifacts to actually make their way into maven central after publishing them.
    r
    c
    • 3
    • 5
  • d

    dave

    02/22/2021, 4:50 PM
    @Saša Šijak you can find react and hotwire examples in the example repo : https://github.com/http4k/examples
    👍 1
    s
    • 2
    • 2
  • r

    Razvan

    02/26/2021, 6:58 PM
    Hi, about using lenses with
    result4k
    if I got a lens declared as:
    Body.auto<T>().toLens().asResult()
    I can only use
    extract
    lens function I can’t use
    inject
    to it, so. what’s best practice ?
    val requestLens = Body.auto<T>().toLens()
    val responseLens = responseLens.asResult()
    d
    n
    • 3
    • 6
  • d

    dave

    02/27/2021, 7:06 PM
    Sure. PR away! 😉
    r
    • 2
    • 3
  • d

    dave

    03/08/2021, 3:48 PM
    I'd recommend you can write a small test class which you can run to generate the contract JSON. As a general rule, we also keep the JSON in Git so that we know when it changes (and we have an approval test to manually approve the changes before it gets committed)
    e
    • 2
    • 7
  • a

    andyg

    03/13/2021, 9:33 PM
    Hi, I submitted a small addition to the docs, regarding regex pattern matchers in URLs. Thanks. https://github.com/http4k/http4k/pull/589
    d
    • 2
    • 1
  • s

    Shingi Chanakira

    03/18/2021, 1:05 PM
    Is there a way to create and manage a session in http4k?
    d
    • 2
    • 2
  • e

    Elizabeth Thomas

    03/20/2021, 4:40 AM
    @dave Is there a way to add the
    servers
    object section to openapi specs using the http4k contracts?
    d
    • 2
    • 1
  • p

    Philipp Mayer

    03/21/2021, 10:27 AM
    Hello everyone, does one of you have a tip what else might be needed to get the live templates running? https://github.com/http4k/intellij-settings I followed the instructions and the repository seems to be added, but unfortunately it seems to not work yet: Thanks in advance!
    d
    • 2
    • 11
  • s

    s4nchez

    03/22/2021, 1:53 PM
    No, it doesn’t
    s
    v
    +3
    • 6
    • 10
  • m

    MrNiamh

    03/23/2021, 9:48 AM
    Heyo, I'm having the same issue as this when using Spring https://github.com/http4k/http4k/issues/320, however with slightly different versions: • spring-boot: 2.3.3 • jackson-module-kotlin: 2.11.2 • http4k: 4.3.5.4 Is there any easy way to check which to downgrade?
    d
    • 2
    • 2
  • s

    s4nchez

    03/23/2021, 11:08 AM
    Out of curiosity, @MrNiamh, how are you using http4k with Spring?
    m
    o
    • 3
    • 5
  • v

    Vojtěch Knyttl

    03/24/2021, 2:50 PM
    Spring allows to add a server section in the OpenApi output:

    https://user-images.githubusercontent.com/401107/112330347-3e2deb80-8cb8-11eb-85e0-d9ed8922165b.png▾

    https://user-images.githubusercontent.com/401107/112330408-4ede6180-8cb8-11eb-8f33-5726b30090f0.png▾

    This allows calling the endpoint on given server and also the path is visible. Is this feasible with http4k?
    s
    • 2
    • 2
  • p

    Philipp Mayer

    03/24/2021, 9:41 PM
    What do you guys recommend as JSON library when one wants to build a native executable with GraalVM? I wanted to try out Moshi, but
    val socketLens = Body.auto<Set<Socket>>().toLens()
    just throws
    No JsonAdapter for class java.util.LinkedHashSet, you should probably use Set instead of LinkedHashSet (Moshi only supports the collection interfaces by default) or else register a custom JsonAdapter.
    and I'm not sure if I really want to add all of that: https://pulseadvancedmedia.co.uk/java/moshi-adapters-for-platform-types-like-arraylist-and-linkedlist/ Any tips what I'm missing? What are you guys using? I'm just used to Jackson, but it makes use of reflection, so I rather not use it for GraalVM I guess. Thanks in advance!
    d
    r
    • 3
    • 8
  • v

    Vojtěch Knyttl

    03/29/2021, 8:54 PM
    Is there a way to route to a single static file? eg:
    routes(
        "/docs/swagger-ui/swagger-ui.css" bind static(Classpath("/swagger-ui/swagger-ui.css")), // read from src/main/resources
        "/docs" bind static(Classpath("META-INF/resources/webjars/swagger-ui/3.25.2"))
    basically I want to override the single
    swagger-ui.css
    file and leave the rest of swagger tools as default. with the example above, the file is ignored and only content from the swagger-ui webjars is served.
    d
    • 2
    • 9
  • d

    dave

    03/31/2021, 1:24 PM
    when you say "modified oauth" - what type of flow is it?
    m
    f
    • 3
    • 8
Powered by Linen
Title
d

dave

03/31/2021, 1:24 PM
when you say "modified oauth" - what type of flow is it?
m

MrNiamh

03/31/2021, 1:28 PM
same flow, but headers are slightly different when requesting the token: • grant_type = tenant_client_credentials • additional header called tenant_id
also out of curiosity, what the answer would be if it was just the standard client credentials?
d

dave

03/31/2021, 1:31 PM
for refresh, you can do it with a simple filter which wraps the http handler, or a cached store (caffiene) with a background refresh happening on a thread.
so is the original "getting" of the credentials also on the serverside?
m

MrNiamh

03/31/2021, 1:38 PM
Okay sweet i'll have a go at that, thanks Yeah (if i'm understanding you correctly) so it's roughly: • Application starts • We get the token • Some time passes and something happens in the application • Application calls the third party, might need to refresh the token before doing so
d

dave

03/31/2021, 1:46 PM
I'd probably create a little service class which is responsible for supplying and refreshing the token (on a background thread) and then a Filter which gets and applies the token to the outgoing request
m

MrNiamh

03/31/2021, 1:51 PM
Sounds like a plan, cheers!
f

fredrik.nordin

04/01/2021, 8:37 AM
This was exactly the strategy we used in the past for handling this scenario. It works well and it's easy to handle any error scenarios too.
View count: 8