July 2017
Beginner to intermediate
358 pages
10h 54m
English
In this last example, we will look at the net/rpc/jsonrpc package that provides a built-in codec for serializing and deserializing to the JSON-RPC standard. We will also look at how we can send these responses over HTTP, whilst you may ask why not just use REST, and to some extent I will agree with you, it is an interesting example to be able to see how we can extend the standard framework.
The StartServer method contains nothing we have not seen before it is the standard rpc server setup, the main difference is line 42 where instead of starting the RPC server we are starting an http server and passing the listener to it along with a handler:
rpc_http_json/server/server.go
33 func StartServer() { 34 helloWorld := new(HelloWorldHandler) ...Read now
Unlock full access