Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registering function as a service #68

Open
krisiasty opened this issue Mar 16, 2019 · 3 comments
Open

registering function as a service #68

krisiasty opened this issue Mar 16, 2019 · 3 comments

Comments

@krisiasty
Copy link

I would like to handle method names which are not in a form "Service.Method", whch seems currently imposible.

One way to handle this would be to have *(Server) RegisterFunc method accepting function and string with a method name as parameters.

Example usage:

func HeartBeat(r *http.Request, args *HeartBeatArgs, reply *HeartBeatReply) error {
    reply.TimeStamp = time.Now().UnixNano()
}

s := rpc.NewServer()
s.RegisterService(heartBeat, "heartBeat")

That way any call with method "heartBeat" should be directed to function HeartBeat.

@ansermino
Copy link

I would also like to know if this is possible. I suspect either using a custom codec or intercepting the http request would make this possible. Any thoughts?

@ansermino
Copy link

Looking at

serviceSpec, methodSpec, errGet := s.services.get(method)
it seems that Intercept nor Before functions would get the chance to modify the method/service name before an error is thrown.

@painhardcore
Copy link

Hit the same issue, but found the solution in divan/gorilla-xmlrpc#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

4 participants