rpc/gateway/handle.go
crusader 8c1c86f021 ing
2017-11-09 17:46:44 +09:00

20 lines
501 B
Go

package gateway
import (
"context"
"io"
"git.loafle.net/commons_go/rpc"
"git.loafle.net/commons_go/rpc/protocol"
)
func Handle(ctx context.Context, sh ServerHandler, codec protocol.ServerCodec, r io.Reader, w io.Writer) error {
return rpc.Handle(sh, codec, r, w, func(codecReq protocol.ServerCodecRequest) (result interface{}, err error) {
var params []string
if params, err = codecReq.Params(); nil != err {
return nil, err
}
return sh.Invoke(ctx, codecReq.Method(), params)
})
}