But what I am looking is to call GET with parameters that can be
objects not just plain values, like for a request like:
While I wouldn't exactly recommend doing this for various reasons, it's technically possible and a breeze to teach Jayrock to do just that.
If you inherit from JsonRpcHandler then there's a method you can override called GetFeatureByName and use it to hook and decorate your service with additional functionality. In fact, all JSON-RPC over HTTP infrastructure in Jayrock is implemented this way, including the help and test pages. The feature gets to decide how the service interacts with the HTTP request. Let's call your feature "tunnel" and when GetFeatureByName gets called with this name, you'll return an object that implements the feature:
protected override object GetFeatureByName(string name) {
return ("tunnel".Equals(name, StringComparison.OrdinalIgnoreCase))
? new JsonRpcGetTunnelProtocol(this);
: base.GetFeatureByName(name);
}
The above can be just thrown in your service class that inherits from JsonRpcHandler (it can also be applied via configuration). I have placed the implementation of JsonRpcGetTunnelProtocol over at (and also attached a copy):
It's fairly small, straightforward and adapted from the
JsonRpcGetProtocol class supplied with Jayrock. It reads the JSON-RPC request from a query string parameter called "req" and uses a JsonRpcDispatcher instance to invoke the call on the service (supplied during construction) and then write out the JSON-RPC response object.
When an HTTP request comes in, JsonRpcHandler looks for the feature name as the value of the an unnamed query string parameter. So to invoke your service using the new tunneling approach, you would invoke with a URL like this:
The details can all be changed but this gives you an idea that it is certainly possible with little effort.
- Atif