19 lines
462 B
Go
19 lines
462 B
Go
|
package gateway
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
|
||
|
"git.loafle.net/commons_go/rpc"
|
||
|
"git.loafle.net/commons_go/rpc/protocol"
|
||
|
)
|
||
|
|
||
|
func Handle(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 []byte
|
||
|
if params, err = codecReq.Params(); nil != err {
|
||
|
return nil, err
|
||
|
}
|
||
|
return sh.Invoke(codecReq.Method(), params)
|
||
|
})
|
||
|
}
|