https://kotlinlang.org logo
Title
s

soulbeaver

04/07/2019, 1:18 PM
Hey y'all, just wanted to pop in and say that I'm enjoying the experience with Http4k so far! I've created a small tabletop service connected to a MongoDB and running and testing it has been pretty sane so far, great work! 🙂
s

s4nchez

04/07/2019, 5:04 PM
I'm glad to hear that, @soulbeaver. If you find and wrinkles with the code or docs, please shout.
s

soulbeaver

04/07/2019, 6:03 PM
Oh yeah, more comprehensive docs would be lovely! I hadn't used this type of framework before (Sinatra inspired with its routing and whatnot?) and figuring out how to create a project with routes organized into different classes wasn't that easy
I'd actually love to know what the preferred way to do that is. I read through the sample projects, but none gave me quite a clear picture. For example, is the intent for every route to be its own Handler class (like in the example https://github.com/alisabzevari/kotlin-http4k-realworld-example-app/blob/master/src/main/kotlin/conduit/handler/CreateArticleHandler.kt) The way I went is to follow a more Dropwizard/Spring approach of creating resource classes (https://github.com/SoulBeaver/d100-service/blob/master/src/main/kotlin/dev/christianbroomfield/d100web/resource/TableResource.kt)
s

s4nchez

04/07/2019, 6:21 PM
That’s good feedback: we could look into adding more implementation patterns. At a high level, I suggest using handlers mainly to do “http-domain” translations. Most of the time it should be just a few lines of code (specially if you’re using lens), and I just define it as a single class if I want to test it individually. That’s not often though, as it’s usually as easy to test against the collection of app routes
s

soulbeaver

04/07/2019, 6:23 PM
Interesting, thanks for the response! I'll try and refactor the app with that insight in mind and see how it feels 🙂
d

dave

04/07/2019, 8:40 PM
@soulbeaver you can see a good example of an app composing modules here: https://github.com/http4k/http4k-by-example There's lots going on (feature-wise) in that demo app, so if you've got any questions just pop them here. 🙂