Show HN: WebRPC – a simple alternative to REST and SOAP
github.com
github.com
>An HTTP 200 is returned on successful completion, and HTTP 500 is returned in the case of an error (i.e. an exception). Note that exceptions are intended to represent unexpected failures, not application-specific errors. No other HTTP status codes are supported.
Now you are just using HTTP as your transport layer, you can very well make it customised to your particular needs rather than defining a spec. This might result in easier client code, but why not use Thrift if that is what you need.
WebRPC isn't meant to be a replacement for REST - just an alternative. Sometimes it's simply more convenient to think in terms of "methods" than "resources".
At Uber, we started with Apache Thrift, but found many things about it limited and broken with dubious code quality for some languages. Furthermore we had more ambitious ideas like application layer sharding (uber/ringpop) and service discovery and routing (uber/hyperbahn).
We're still using the thrift protocols (uber/thriftrw) with our rpc library (uber/tchannel), but could have built on top of another IDL format like protobufs (v3).
For those curious about the RPC interface, just check out: https://tchannel.readthedocs.org/en/latest/
The interface supports all sorts of things
This is all over TCP right now and designed for performance and service to service communication, but there is nothing preventing the addition of HTTP (via XHR or WebSockets) as a transport for allowing web apps to speak with tchannel services. I contributed to the Apache Thrift implementation that allows this (https://github.com/apache/thrift/blob/master/lib/nodejs/lib/...). The implementation for tchannel would be similar, but rely on XHR/WS in the browser and the `http` module instead of the `net` module in NodeJS on the server. It's trivial to write a proxy frontend that relays TJSONProtocol on the frontend to a Thrift binary protocol like TBinaryProtocol or TCompactProtocol.
https://github.com/uber/hyperbahn https://github.com/uber/tchannel https://github.com/uber/ringpop-node https://github.com/uber/ringpop-go https://github.com/uber/idl https://github.com/uber/tcurl https://github.com/uber/tcap
etc.
Thrift must have been written by people who though SOAP was too easy to use and that developer lives should be made harder.
I see that it is using JSON instead of XML.
> Support currently exists for implementing web RPC services in Java, and consuming services in Java, Objective-C/Swift, or JavaScript.
While I may personally feel that JSON is a better format than XML, there are a implementations of XML-RPC for almost all languages and platforms which is a huge advantage.
The client libraries all use POST internally - GET is primarily useful for testing and debugging (so you can easily execute a method in the browser).