Hi all,
Very noob in both Go and Gorilla. Trying to put up a basic server for sucking in a JSON-RPC request, and, for now, just dumping out the request params. Test client is an existing
application that sends over a half-dozen params as mostly strings. I was able to get the simple URL-parsing Gorilla example to work (parsing name: from the URL) but on this
project everything I want is in the JSON and I will only ever get a single URL.
I built a program "rpc.go" (I'll include in a bit) which seems like it has everything the Gorilla example has. When I "go run rpc.go" in a couple of seconds the command prompt re-appears,
and there seems to be no trace of rpc.go in the process list (running OS X, fyi). But no error exits or anything. If I run the sample client, I just get a "connection refused".
If anyone can take a look, maybe run it, and see whether I'm missing something (may not have the client set up right to call this, either), I'd appreciate this greatly.
Thanks! Ken
here's the server code (rpc.go):
package main
import (
"net/http"
)
func Init() {
s := rpc.NewServer()
s.RegisterCodec(json.NewCodec(), "application/json")
s.RegisterService(new(HelloService) , "")
http.Handle("/pv/v1/", s)
}
type HelloArgs struct {
// Who string
method 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.method + "!"
return nil
}
func main() {
Init()
}