Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    David Denton
    @daviddenton
    Our links are wrong ... I'll fix it.
    David Denton
    @daviddenton
    @scap1784 I've worked it out. The problem was that you've passed a reference to ::ping instead of calling ping() - in this case, because the endpoint hasn't got any parameters, you don't need to pass it as a function reference and instead just use a val of HttpHandler. I've updated the gist with a working version: https://gist.github.com/daviddenton/7bfeea6347b1d0e925e9ef04ac94c2a0
    David Denton
    @daviddenton
    I've also updated the example for the contract to have an equivalent endpoint with no params - which hopefully should stop anyone else having the same problem :)
    scap1784
    @scap1784
    AWESOME! thanks
    David Denton
    @daviddenton
    Np. 😀
    (And make sure you get on the kotlin slack... :smile: )
    Tim Helmstedt
    @thelmstedt
    Hi - I'm just starting out so this might be obvious. I'm trying to (de)serialise things via jackson, and can't figure out how to provide my own ObjectMapper definition. I see ConfigurableJackson takes an object mapper, but can't figure out how to use subsequent extension methods use it in eg inline fun <reified T : Any> Response.jsonPojo(pojo: T) = this.with(Body.auto<T>().toLens() of pojo)
    Nice work on the lib btw, besides this it's been trivial to get started! :)
    Where Body.auto is extended via ConfigurableJackson
    David Denton
    @daviddenton
    @thelmstedt glad to hear that you like the lib :) With regards to custom ObjectMappers, you can define your own object like so:object MyJackson : ConfigurableJackson(ObjectMapper() .registerModule(KotlinModule()) .configure(FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(FAIL_ON_IGNORED_PROPERTIES, false) .configure(USE_BIG_DECIMAL_FOR_FLOATS, true) .configure(USE_BIG_INTEGER_FOR_INTS, true) )
    Then you can just import MyJackson.auto to activate the Jackson marshalling lenses
    @thelmstedt you might also want to check out the end of this page if you're using auto-marshalling as there are a couple of Jackson-specific gotchas that can throw you: https://www.http4k.org/guide/modules/message_formats/
    Tim Helmstedt
    @thelmstedt
    @daviddenton Thanksthat worked - I just didn't understand extension function resolution in general.
    I managed to get jackson to stop messing with field names with .configure(MapperFeature.USE_STD_BEAN_NAMING, true).setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE) - it requires everything to be annotated with @JsonProperty but at least it stopped messing with casing
    David Denton
    @daviddenton
    @thelmstedt glad it's working. We generally tend to go the other way, and just annotate the fields that are causing problems... that way you don't need the PropNamingStrat. Or use GSON :)
    @thelmstedt if it helps, you can also use this app to generate data class definitions for JSON messages https://http4k-data-class-gen.herokuapp.com/
    Malcolm Crum
    @crummy
    hi folks. My routes have got a little convoluted, is there a way I can print them out? app.printRoutes() or something?
    David Denton
    @daviddenton
    @crummy not really tbh. You can split them out into sub-apps based on context, which helps - but there isn't really a good way (currently) to describe them as a whole. We'll give it a think and see if there's something we can come up with. 🙃
    Malcolm Crum
    @crummy
    ok, thanks for the advice
    Erlend Hamnaberg
    @hamnis
    Hey all. I'm wondering if the remote ip is exposed as a header or something in http4k. If not, I guess I can create a servlet filter which sets it.
    David Denton
    @daviddenton
    We don't explicitly expose the remote IP by default - mainly because it's so unreliable in our experience. Every proxy may alter the "real" end location, or there's x-forwarded for - once again that's usecase specific - so it's probably best to do something custom for your usecase.
    Erlend Hamnaberg
    @hamnis
    right. thanks
    Chris James
    @quii_twitter
    Howdy!
    I think I have come across a bug with WebDriver. It seems when you submit a form with checkboxes in them the form values will be submitted irrespective of whether they are checked or not. Im not 100% sure if its wrong or not but ive done a fork, here's the commit showing what I think is wrong quii/http4k@4ddec92
    Side point, it seems my intellij is configured slightly differently to whatever you have, but I cant see an editorconfig thing to make it align. Is there a way of making my thing consistent with what you want?
    poke @daviddenton @s4nchez
    It does look like a bug though as when i use the WebDriver and print what the server recieves it gets all form values whether they are checked but when I do it in real life it works as intended
    Ivan Sanchez
    @s4nchez
    @quii_twitter I just saw your PR and it does look like a bug indeed. Don’t worry about your formatting. I’ll merge it in as soon as I can.
    Chris James
    @quii_twitter
    Thanks!
    Ivan Sanchez
    @s4nchez
    It’s released on 3.94.0 (available on jcenter, on its way to maven central)
    Chris James
    @quii_twitter
    Lovely turnaround time :)
    Ivan Sanchez
    @s4nchez
    Incidentally, we tend to hang out in the http4k channel in the kotlin slack, so don’t be surprised if we take a while to respond here
    Chris James
    @quii_twitter
    Yeah i just didnt have slack setup for kotlin and i was being lazy, gitter is a bit slicker in that regard
    Tobi
    @ttheuer
    Heyo! Slack invite doesn't seem to work, so I ask here: Does http4k work with Kotlin/Native?
    David Denton
    @daviddenton
    @ttheuer GraalVM is supported out of the box for the ApacheServer or SunHttp backends (within the limits of Graal/Substrate), but we rely on quite a few of the JDK classes which aren't supplied by the Kotlin stdlib, so true multiplatform isn't available. See here for details: http4k/http4k#186
    Tobi
    @ttheuer
    Awww
    Thanks, though!
    David Denton
    @daviddenton
    np - we're missing DateTime IO abstractions (the latter is more important) to be able to offer this. TBH, I think this will be somewhat of a problem for the real takeup of true MultiPlatform Kotlin.
    Tobi
    @ttheuer
    Yeah, I feel like Kotlin/Native is more of a toy project, right now...
    David Denton
    @daviddenton
    I don't envy JB - proper DateTime APIs are a total nightmare to implement correctly... :)
    Tobi
    @ttheuer
    I bet!
    David Valenzuela
    @val171001
    Hi, I'm working on a simple server to handle webhook requests. On one of my routes uses POST to receive the data but the bodyString() method is not working. I get the error "Exception in thread "HTTP-worker-2" java.lang.NoSuchMethodError: kotlin.io.ByteStreamsKt.readBytes(Ljava/io/InputStream;)" Anyone have experience this before or have any idea on what could be causing this?
    Ivan Sanchez
    @s4nchez
    @val171001 which server backend are you using?
    David Valenzuela
    @val171001
    @s4nchez I'm using ApacheServer
    Ivan Sanchez
    @s4nchez
    @val171001 Hmm are you sure you have the Kotlin library available in your classmate at runtime?
    Also make sure the Kotlin version is compatible. It may be the case you’re on a version that’s just too old
    David Valenzuela
    @val171001
    @s4nchez I'm going to check that. Thanks
    Ivan Sanchez
    @s4nchez
    @val171001 incidentally, if you’re on the Kotlin Lang slack, feel free to ask in the #http4k channel there as there are more people helping each other there
    David Valenzuela
    @val171001
    I tried to join, but as i read here seems that the invite is not working
    David Denton
    @daviddenton
    @val171001 if you DM me your email I'll try to send you an invite from inside the slack