Created
August 1, 2012 21:44
-
-
Save kisielk/3231027 to your computer and use it in GitHub Desktop.
Server in golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import jsonrpclib | |
s = jsonrpclib.Server('http://localhost:1234/rpc') | |
s.Say('Kamil') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"code.google.com/p/gorilla/rpc" | |
"code.google.com/p/gorilla/rpc/json" | |
"net/http" | |
) | |
type HelloArgs struct { | |
Who string | |
} | |
type HelloReply struct { | |
Message string | |
} | |
type HelloService struct{} | |
func (h *HelloService) Say(r *http.Request, args *HelloArgs, reply *HelloReply) error { | |
reply.Message = "Hello, " + args.Who + "!" | |
return nil | |
} | |
func main() { | |
s := rpc.NewServer() | |
s.RegisterCodec(json.NewCodec(), "application/json-rpc") | |
s.RegisterCodec(json.NewCodec(), "application/x-www-form-urlencoded") | |
s.RegisterService(new(HelloService), "") | |
http.Handle("/rpc", s) | |
http.ListenAndServe(":1234", nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File "<stdin>", line 1, in <module> | |
File "/Network/Cluster/home/kamil/.virtualenvs/jsonrpc/lib/python2.6/site-packages/jsonrpclib/jsonrpc.py", line 274, in __call__ | |
return self.__send(self.__name, args) | |
File "/Network/Cluster/home/kamil/.virtualenvs/jsonrpc/lib/python2.6/site-packages/jsonrpclib/jsonrpc.py", line 224, in _request | |
response = self._run_request(request) | |
File "/Network/Cluster/home/kamil/.virtualenvs/jsonrpc/lib/python2.6/site-packages/jsonrpclib/jsonrpc.py", line 242, in _run_request | |
verbose=self.__verbose | |
File "/opt/zymeworks/platform/4.0.22/lib/python2.6/xmlrpclib.py", line 1243, in request | |
headers | |
xmlrpclib.ProtocolError: <ProtocolError for localhost:1234/rpc: 400 Bad Request> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment