Giter Site home page Giter Site logo

Comments (8)

markaren avatar markaren commented on June 18, 2024

Yeah, you are right. This is a yaj-rpc thing, which allows you to have several services per end-point.

from yaj-rpc.

markaren avatar markaren commented on June 18, 2024

I could of course relax the requirement. For instance if only one service is defined. The '.' could be omitted.

from yaj-rpc.

markaren avatar markaren commented on June 18, 2024

The following backwards compatible change allows you to omit the '.' when only one service has been defined:

private fun handle(req: RpcRequest): String? {
        val id = req.id
        val service: RpcService
        val methodName: String

        val split = req.methodName!!.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }
        if (split.size == 2) {
            val serviceName = split[0]
            if (!services.containsKey(serviceName)) {
                val msg = "No such registered service '$serviceName'"
                LOG.warn(msg)
                return createErrorResponse(id, RpcError.ErrorType.METHOD_NOT_FOUND, msg)
            }
            service = services[serviceName]!!
            methodName = split[1]
        } else if (services.size == 1) {
            service = services.values.toList()[0]
            methodName = req.methodName!!
        } else {
            val msg = "Multiple services defined and method does not use '.' to separate service and method!"
            LOG.warn(msg)
            return createErrorResponse(id, RpcError.ErrorType.INVALID_REQUEST, msg)
        }

       ...
    }

Will push the change upstream

from yaj-rpc.

markaren avatar markaren commented on June 18, 2024

@ligi I will release a version 0.10.1 of the library with the above changes included soon.

from yaj-rpc.

ligi avatar ligi commented on June 18, 2024

thanks! will try it out and consume it via jitpack in the meantime. What would be super awesome to squeeze into the 0.10.1 release: a way to change the context - currently I need to do:

class MyRPCServer(handler: RpcHandler) : RpcHttpServer(handler) {
    override val context: String
        get() = "/"
}

It would be great if there could be a direct way to change this.

from yaj-rpc.

markaren avatar markaren commented on June 18, 2024

Like this:

open class RpcHttpServer @JvmOverloads constructor(
        val handler: RpcHandler,
        override val context: String = "/jsonrpc"
) 

?

from yaj-rpc.

ligi avatar ligi commented on June 18, 2024

yes - LGTM

from yaj-rpc.

ligi avatar ligi commented on June 18, 2024

FIY: just tried out the patch for the opened issue via jitpack and it works for me - thanks for the really fast fix!

from yaj-rpc.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.