Comments (8)
Yeah, you are right. This is a yaj-rpc thing, which allows you to have several services per end-point.
from yaj-rpc.
I could of course relax the requirement. For instance if only one service is defined. The '.' could be omitted.
from yaj-rpc.
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.
@ligi I will release a version 0.10.1 of the library with the above changes included soon.
from yaj-rpc.
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.
Like this:
open class RpcHttpServer @JvmOverloads constructor(
val handler: RpcHandler,
override val context: String = "/jsonrpc"
)
?
from yaj-rpc.
yes - LGTM
from yaj-rpc.
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)
- type of ID is changed HOT 10
- Type wrapped as string HOT 2
- Upload artifacts to bintray HOT 1
- typo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaj-rpc.