Search code examples
kotlinjson-rpchttp4k

How to use http4k-jsonrpc from http4k project?


According http4k documentation to configure JSON-RPC server I should use JsonRpc.auto or JsonRpc.manual, but unfortunately I can't find any example. API doc contains something like:

fun <NODE : Any> auto(json: JsonLibAutoMarshallingJson<NODE>, errorHandler: ErrorHandler = defaultErrorHandler, fn: Auto<NODE>.() -> Unit): JsonRpcService<NODE>

and I don't know, which implementations of interfaces I should use.

fun main() {
    val app: HttpHandler = JsonRpc.auto(???)
    app.asServer(Jetty(8080)).start()
}


Solution

  • Looks like there were some missing docs. There is now an example on the site, but in future the best port of call is to look at the tests first. :)

    Here's the example: https://www.http4k.org/guide/modules/jsonrpc/