Hey y'all, just wanted to pop in and say that I'm ...
# http4k
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! 🙂
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)
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
Interesting, thanks for the response! I'll try and refactor the app with that insight in mind and see how it feels 🙂