Astn/JSON-RPC.NET

Url "routing" to group methods

bluerv opened this issue · 3 comments

(if I could, I'd mark this low priority). One of the things I like about this library is that it doesn't overcomplicate things like forcing you to define routing paths for everything.

However, I have a circumstance where I'm trying to simulate another system which does have multiple paths at the end of which support different methods... so:

/foo/bar/baz supports all "baz"-object related methods where as /foo/bar/quz supports all "quz"-object related methods. Ignoring, for a moment, that this makes it look more like REST than JSON-RPC, is there any way to do this, or would there be any interest in having this feature (besides me at least)?

Astn commented

Interesting idea. I think the biggest issue to think though would be what happens to the json-rpc method name vs the route. Which one would take priority in determining which method to invoke. Also you can already use route type of info to have the method be handled by another instance of the handler.
See CanCreateAndRemoveSession for an example.
https://github.com/Astn/JSON-RPC.NET/blob/c0a6d05741c6197a3ffaccbe2ee414b049d7d7d1/AustinHarris.JsonRpcTestN/Test.cs

Based on what I have seen in the other solution (Java based), it treats the URL like a namespace and class, and then the method name lives on the class.
So, /foo/bar/baz  method quz
would equate to a namespace of "foo.bar" a class of "baz" and a method "quz".
Given that, the route would take priority, then the method would take over.
Thoughts?
I looked at the sample, but I didn't follow it.  I'll have to spend more time reviewing it.

On Monday, February 29, 2016 9:57 PM, Austin Harris <notifications@github.com> wrote:

Interesting idea. I think the biggest issue to think though would be what happens to the json-rpc method name vs the route. Which one would take priority in determining which method to invoke. Also you can already use route type of info to have the method be handled by another instance of the handler.
See CanCreateAndRemoveSession for an example.
https://github.com/Astn/JSON-RPC.NET/blob/c0a6d05741c6197a3ffaccbe2ee414b049d7d7d1/AustinHarris.JsonRpcTestN/Test.cs—
Reply to this email directly or view it on GitHub.

Astn commented

After looking at this again I think you can do this via:

Given a "/foo/bar/baz" -> Any portion of that can be mapped as the session id. Then you could use some other portion as the Context.

// Setup routes like:
Handler.RegisterInstance("/foo/bar", new Foo(new Bar))
// Process are request like:
Handler.GetSessionHandler("/foo/bar").Handle( ..Rpc.., "/baz" /*Per Invocation Context*/ , ...)