David Hamilton
01/26/2022, 2:09 PMhttp4k-server-jetty
is pulling in (through Jetty itself) an alpha version of SLF4J 2.0 as a transitive dependency (and that there seem to be conflicts with SLF4J 1.x).
Anyone else notice that - and have a workaround? Does it just need an exclusion? 😄christophsturm
02/08/2022, 8:14 PMdave
02/09/2022, 1:02 PMElizabeth Thomas
03/03/2022, 6:09 PMMarc
03/18/2022, 1:49 PM"/tokens" bind contract {
routes += TokenID.path bind contract {
routes += "/" bindContract GET to ::getToken
routes += "/" bindContract GET to ::getToken
routes += "/" bindContract PUT to ::putToken
routes += "/" bindContract DELETE to ::removeToken
routes += "/user" bindContract GET to ::getUser
}
}
Marc
03/18/2022, 1:49 PMDan T
03/21/2022, 3:45 PM0.0.0.0
, and I don't see a way to modify the configuration using the ServerConfig object. So the only option I'm aware of currently is to create my own class similar to Undertow. Before I do that, I thought I'd double-check in case I'm missing something or this use case changes the perspective. Thanks.David Hamilton
03/22/2022, 6:38 PMAccept
header provided by client, providing json content only when specifically requested by the client.
However both my routes are now returning 405
whereas the fallback handler worked fine without the nested route:
"/mappings" bind routes(
Method.GET to routes(
header("Accept", "application/json") bind ingressTracingLoggingFilter.then(mappingsAdminJsonHandler),
Fallback bind ingressTracingLoggingFilter.then(mappingsAdminReportHandler)
),
<http://Method.POST|Method.POST> to someOtherHandler
),
What am I doing wrong?MrNiamh
03/23/2022, 2:00 PMMarc
03/29/2022, 1:56 PMDanielZ
04/01/2022, 9:26 AMEnvironment
in following example the second test fails:
import com.github.stefanbirkner.systemlambda.SystemLambda
import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import org.http4k.cloudnative.env.Environment
import org.http4k.cloudnative.env.EnvironmentKey
import org.http4k.cloudnative.env.Port
import org.http4k.lens.string
import org.junit.jupiter.api.Test
private val developmentPort = Port(9999)
private val defaultPort = Port(8080)
private const val developmentProfile = "development"
private const val SPRING_PROFILE_ACTIVE = "SPRING_PROFILE_ACTIVE"
private val springProfileLens = EnvironmentKey.string().defaulted(SPRING_PROFILE_ACTIVE, "")
class ConfigurationTest {
@Test
fun configuration1() {
assertThat(Configuration.serverPort, equalTo(defaultPort))
}
@Test
fun configuration2() {
SystemLambda.withEnvironmentVariable(SPRING_PROFILE_ACTIVE, developmentProfile).execute {
assertThat(Configuration.serverPort, equalTo(developmentPort))
}
}
@Test
fun configuration3() {
assertThat(Configuration.serverPort, equalTo(defaultPort))
}
}
object Configuration {
val serverPort: Port
get() {
println("selected profile: ${springProfileLens(environment)}")
println("selected profile (env): ${System.getenv(SPRING_PROFILE_ACTIVE).orEmpty()}")
return when (springProfileLens(environment)) {
developmentProfile -> developmentPort
else -> defaultPort
}
}
private val environment: Environment
get() = Environment.ENV overrides Environment.JVM_PROPERTIES
}
For some reasons I don’t understand I receive following output:
selected profile:
selected profile (env): development
I expected my springProfileLens(environment)
would return development
but it’s not. Do you have an idea where I’m wrong?
Thanks a lotGopal S Akshintala
04/05/2022, 4:19 PMs4nchez
04/12/2022, 6:43 PMJames Richardson
04/13/2022, 1:28 PMMrNiamh
04/14/2022, 11:52 AMException in thread "main" java.lang.NoSuchMethodError: 'org.http4k.core.Filter org.http4k.filter.ServerFilters$CatchAll.invoke$default(org.http4k.filter.ServerFilters$CatchAll, kotlin.jvm.functions.Function1, int, java.lang.Object)'
at org.http4k.server.Http4kUndertowHttpHandler.<init>(Http4kUndertowHttpHandler.kt:20)
at org.http4k.server.Undertow.toServer(Undertow.kt:24)
at org.http4k.server.PolyServerConfig$DefaultImpls.toWsServer(PolyServerConfig.kt:15)
at org.http4k.server.Undertow.toWsServer(Undertow.kt:19)
at org.http4k.server.RealtimeExtensionsKt.wsHandlerAsServer(realtimeExtensions.kt:19)
at com.asurafin.trading.mstar.stream.WsPolyTestKt.main(WsPolyTest.kt:62)
at com.asurafin.trading.mstar.stream.WsPolyTestKt.main(WsPolyTest.kt)
When using jetty they get:
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in thread "main" java.lang.NoSuchMethodError: 'java.util.stream.Stream org.eclipse.jetty.util.TypeUtil.serviceStream(java.util.ServiceLoader)'
at org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry.<init>(WebSocketExtensionRegistry.java:33)
at org.eclipse.jetty.websocket.core.WebSocketComponents.<init>(WebSocketComponents.java:55)
at org.eclipse.jetty.websocket.core.WebSocketComponents.<init>(WebSocketComponents.java:49)
at org.eclipse.jetty.websocket.core.WebSocketComponents.<init>(WebSocketComponents.java:43)
at org.http4k.server.Jetty.toServer(jetty.kt:38)
at org.http4k.server.PolyServerConfig$DefaultImpls.toWsServer(PolyServerConfig.kt:15)
at org.http4k.server.Jetty.toWsServer(jetty.kt:26)
at org.http4k.server.RealtimeExtensionsKt.wsHandlerAsServer(realtimeExtensions.kt:19)
They’re still investigating themselves what could be causing it, but just wondering if anyone has seen this before as the exceptions aren’t massively helpfulMichael Hayes
04/14/2022, 3:27 PMCorsPolicy(OriginPolicy.AllowAll(), listOf("content-type", "Authorization"), Method.values().toList(), true)
Raf Szałański
04/21/2022, 3:21 PMid: String
, name: String
and count: Int
and the caller forgets to send the count
or maybe sends a boolean there. When parsing such request, http4k will likely throw a lens failure, e.g:
body 'body' must be object
org.http4k.lens.LensFailure: body 'body' must be object
I found this piece of code recently https://github.com/http4k/http4k/blob/master/http4k-core/src/main/kotlin/org/http4k/lens/Validator.kt and thought it’d be fantastic to make it work with json parsing.
Unfortunately, I can only see it being used with web forms and not sure it works with json https://github.com/http4k/http4k/blob/master/http4k-core/src/test/kotlin/org/http4k/lens/ValidatorTest.ktCésar
04/23/2022, 8:02 AMdave
05/06/2022, 7:00 AMGopal S Akshintala
05/08/2022, 2:47 PMPKIX path building failed
. I migrated from JavaHttpClient()
to ApacheClient()
and built it like this to disable SSL verification. Yet getting the same issue. What am I missing?
Apache4Client(
client = HttpClients.custom()
.setDefaultRequestConfig(
RequestConfig.custom()
.setRedirectsEnabled(false)
.setCookieSpec(CookieSpecs.IGNORE_COOKIES)
.build()
).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build()
)
This is the exception log:
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:370)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:313)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:654)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369)
at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:200)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1500)
Attached full log in the thread. Here is my usage (it’s a small app): https://github.com/overfullstack/revoman-root/blob/f43bc461e580eae650c84ce179645423118e1eba/src/jvmMain/kotlin/org/revcloud/ReVoman.kt#L84-L84James Richardson
05/09/2022, 6:01 AMMatt
05/10/2022, 10:52 AMgreetRoute()
example (https://www.http4k.org/guide/reference/contracts/), how would I apply a filter before the greet(nameFromPath: String)
handler is invoked?Philipp Mayer
05/15/2022, 5:05 PMGopal S Akshintala
05/17/2022, 1:02 PMurlStr.urlEncoded()
is turning my URL into this: https%3A%2F%<http://2Fpokeapi.co|2Fpokeapi.co>%2Fapi%2Fv2%2Fpokemon%3Flimit%3D10
which is invalid. What’s the right and http4k idiomatic way to do it?Fabien Hebuterne
05/24/2022, 3:46 PMSlackbot
06/01/2022, 9:48 PMDmitry Kandalov
06/06/2022, 6:02 PMdave
06/06/2022, 6:59 PMDanielZ
06/09/2022, 7:40 AM{
"@timestamp": "2022-06-02T12:00:00.0Z",
"metadata": {...},
"event": {...}
}
What would be the best approach?
Basically copying whole events.kt
file and adopt it with a customized MetadataEvent
?
Or is there a better option?